Skip to content

fix(agent): compact before the completion budget overflows the window - #1517

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-10833-reserve-completion-budget
Oct 18, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-10833-reserve-completion-budget

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Compaction occupancy is 60% of the context window minus the reserved completion budget.
  • A follow-up whose usage or live estimate plus that reservation meets the window compacts before the next infer.
  • An inference error that names a context length compact-and-retries even when the category is not already context_overflow. The recovery cap stays at 2. A message that only says "exceeds the maximum" or "reduce the length" does not fold the transcript.
  • A server sentence that names maximum context length of N pins N for that model for the rest of the process.

Verification

  • bun test src/agent/compaction.test.ts src/provider/context-window-thresholds.test.ts covers the reservation, the follow-up preflight, the two-retry cap, the loose-phrase negative, and the server pin.
  • pre-commit tsc --noEmit and bun build pass on this commit.

Fixes CL-10833

@linear-code

linear-code Bot commented Oct 18, 2026

Copy link
Copy Markdown

CL-10833

@corbits-triage

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

@TheGreatAxios
TheGreatAxios merged commit 79a5940 into main Oct 18, 2026
13 checks passed
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.

1 participant