Skip to content

fix(runtime): restore session ID after compaction and drop forced overflow compaction - #466

Merged
hetaoBackend merged 2 commits into
mainfrom
fix/session-id-after-compaction
Oct 9, 2026
Merged

hetaoBackend merged 2 commits into
mainfrom
fix/session-id-after-compaction

Conversation

@hetaoBackend

@hetaoBackend hetaoBackend commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #459 and #460.

  • Drop the forced compaction after oversized requests. fix: stop retrying oversized requests and recover with one forced compaction #460 added a one-shot compact-and-resend after a provider rejected a main-agent request as too large. The resend skipped the normal before-LLM pipeline, so request-level transforms were not reapplied to it: the computer-use screenshot cap, and the session identity restoration below. This removes contextOverflowRecoveryHook, the force: '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. isLLMRequestOversized becomes module-private, and its cases are asserted through isLLMDeterministicRequestRejection.
  • Restore the session ID after compaction drops it. perf(runtime): trim per-turn reminders (budget thresholds, minute time, session id once) #459 omits YOUR SESSION ID from 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 hidden session_identity_reminder when 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:tui all pass.
  • pnpm test:capabilities: 217 files, 5421 passed, 17 skipped. pnpm test:policy: 142 passed.
  • Focused: the new session-identity-reminder.test.ts, plus llm-retry, automatic-context-compactor, executor, context-compaction (296 passed).

Not verified: real-model behaviour after compaction, and Windows.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

hetaoBackend and others added 2 commits October 9, 2026 17:48
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>
@hetaoBackend
hetaoBackend merged commit c460f08 into main Oct 9, 2026
13 checks passed
@hetaoBackend
hetaoBackend deleted the fix/session-id-after-compaction branch October 9, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant