Skip to content

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

Closed
TheGreatAxios wants to merge 1 commit into
mainfrom
cl-10833-compact-before-a-reserved-completion-budget-overflows-the
Closed

TheGreatAxios wants to merge 1 commit into
mainfrom
cl-10833-compact-before-a-reserved-completion-budget-overflows-the

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Compaction occupancy is 60% of the context window minus the reserved completion budget, so a prompt that fits the advertised window cannot still overflow once maxTokens is added.
  • A user message or tool follow-up whose usage or live estimate plus that reservation meets the window compacts before the next infer.
  • An inference error whose text is a context overflow compact-and-retries even when the provider did not tag the category context_overflow. The recovery cap stays at 2.
  • A server sentence that names maximum context length of N pins N for that model for the rest of the process, ahead of the advertised window, without writing settings.

A custom endpoint can advertise a larger window than it enforces. The pin is what makes the next threshold use the server's limit after the first rejection.

Verification

  • bun test src/agent/compaction.test.ts src/provider/context-window-thresholds.test.ts src/provider/context-window.test.ts — 100 pass
  • pre-commit tsc --noEmit and bun build pass
  • full bun run test was not run

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

Copy link
Copy Markdown
Collaborator Author

Superseded by the v0.3.41 branch, which includes this compaction commit alongside the Option-chord work.

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