Repository navigation
fix(runtime): restore session ID after compaction and drop forced overflow compaction - #466
Merged
Merged
Conversation
Remove the one-shot compact-and-resend recovery that ran after a provider rejected a main-agent request as too large. The resend bypassed the normal before-LLM pipeline, so request-level transforms (screenshot caps, session identity restoration) were not reapplied to it. Oversized requests (HTTP 413, request_too_large, the local request-body check, context-window overflow) are still classified as deterministic rejections and are not resent unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
The turn reminder omits `YOUR SESSION ID` while earlier history already shows it. When automatic compaction summarizes that history away, the model would lose its own session ID for the rest of the turn. A stateless post-compaction hook now appends a hidden session identity reminder when no visible user message or identity reminder after the latest compaction carries the ID (before the current user message on initial compaction, at the tail mid-turn). The preparation check counts that reminder too, so the next turn does not repeat the ID. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #459 and #460.
contextOverflowRecoveryHook, theforce: 'context_overflow_recovery'compaction input, and the forced compaction limits. Oversized requests (HTTP 413,request_too_large, the local request-body check, context-window overflow) are still classified as deterministic rejections and are not resent unchanged.isLLMRequestOversizedbecomes module-private, and its cases are asserted throughisLLMDeterministicRequestRejection.YOUR SESSION IDfrom the turn reminder while earlier history already shows it. If automatic compaction (including the initial compaction of the same turn) summarizes that history away, the model lost its session ID until the next turn. A stateless post-compaction hook now appends a hiddensession_identity_reminderwhen no visible user message or identity reminder after the latest compaction carries the ID. On initial compaction it goes before the current user message; mid-turn it goes at the tail. The preparation check counts this reminder too, so the next turn does not repeat the ID.Verification
pnpm typecheck,pnpm build,pnpm check:standalone,pnpm check:source,pnpm check:tsconfig,pnpm test:release-tools,pnpm lint:tuiall pass.pnpm test:capabilities: 217 files, 5421 passed, 17 skipped.pnpm test:policy: 142 passed.session-identity-reminder.test.ts, plusllm-retry,automatic-context-compactor,executor,context-compaction(296 passed).Not verified: real-model behaviour after compaction, and Windows.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.