Skip to content

fix(session): apply compaction.reserved to models without limit.input#38843

Open
kagura-agent wants to merge 1 commit into
anomalyco:devfrom
kagura-agent:fix/overflow-reserved-branch-b
Open

fix(session): apply compaction.reserved to models without limit.input#38843
kagura-agent wants to merge 1 commit into
anomalyco:devfrom
kagura-agent:fix/overflow-reserved-branch-b

Conversation

@kagura-agent

@kagura-agent kagura-agent commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #38835

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

compaction.reserved is silently ignored for models without limit.input. The usable() function in overflow.ts computes reserved but only subtracts it in the limit.input branch — the fallback branch (used by most models.dev entries that only declare context + output) drops it entirely.

The fix adds - reserved to the fallback branch so reserved takes effect consistently regardless of whether limit.input is declared.

How did you verify your code works?

Added test/session/overflow.test.ts with 12 unit tests covering both branches of usable() (with/without limit.input), default vs explicit compaction.reserved, outputTokenMax override, and isOverflow() integration. All pass.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The usable() function in overflow.ts has two branches: one for models
with limit.input and one without. The reserved token buffer was only
subtracted in the limit.input branch, silently ignoring the user's
compaction.reserved config for models that only declare context + output
limits (which is common — most models.dev entries lack limit.input).

Fixes anomalyco#38835
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. contributor and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compaction.reserved silently ignored for models without limit.input (e.g. GLM-5.2) — revival of #13980

1 participant