Skip to content

fix(session): resolve session overflow detection timing gaps#37194

Closed
johncoffee715 wants to merge 3 commits into
anomalyco:devfrom
johncoffee715:dev
Closed

fix(session): resolve session overflow detection timing gaps#37194
johncoffee715 wants to merge 3 commits into
anomalyco:devfrom
johncoffee715:dev

Conversation

@johncoffee715

Copy link
Copy Markdown

Problem

Session overflow detection has several timing gaps:

  • isOverflow() only checks previous step tokens, missing pending context
  • usable() caps output reservation at 20K instead of full maxOutputTokens
  • No overflow check after large tool outputs
  • Session stops silently when compaction itself overflows

Changes

  • compaction.ts: Add pendingTokens param to isOverflow() for future context estimation
  • overflow.ts: Remove COMPACTION_BUFFER cap, reserve full maxOutputTokens
  • processor.ts: Check overflow after completeToolCall() for early detection
  • compaction.ts: Return 'continue' (not 'stop') when compaction overflows with auto=true

Verification

  • All 52 existing compaction tests pass (0 failures)
  • No regressions in session creation, tool execution, or compaction flow

Fixes #17340, Fixes #32656, Fixes #10634, Fixes #13946

…t models

Remove COMPACTION_BUFFER (20K) constant and Math.min wrapper so usable()
reserves the full maxOutputTokens instead of capping at 20K.

Fixes: anomalyco#32656
…inue after compaction overflow

Two fixes:
1. isOverflow() now accepts pendingTokens to estimate upcoming context
2. When compaction itself overflows, session returns 'continue' instead of
   'stop' if auto-compaction is enabled, allowing the synthetic Continue...
   message to be created

Fixes: anomalyco#17340, anomalyco#13946
…rflow on next step

After completeToolCall(), estimate output tokens and check overflow before
the next step begins. This catches large tool outputs that push context
past the limit before step-finish.

Fixes: anomalyco#10634
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 16, 2026
@github-actions github-actions Bot closed this Jul 16, 2026
@johncoffee715

Copy link
Copy Markdown
Author

caso queira encerrar eu deixei uma copia em meu repositoi, obrigado..!

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