Repository navigation
Conversation
There was a problem hiding this comment.
This looks right to me. I ran the #53107 reproduction from source against a mock gateway that returns 413 for request bodies over 200 KB. On the base, the turn with the image and every --continue after it fail, and the gateway only ever sees requests that still contain the image. With this PR, the 413 leads to one summary request without the image, then a rebuilt request without the image, and both that turn and the next one succeed. In the context-overflow control case, the request rebuilt after compaction also no longer resends the image. The runner, step and compaction tests (289) and typecheck:tsc pass.
Public API: unchanged. The recoverOverflow signature and the new payload value for the Trigger reason are internal to packages/core.
One behaviour to be aware of, not blocking: when the image that triggers the rejection is attached to the current turn, the model then answers that turn with the image left out (the summary says [image/png omitted]) and the user isn't told. That's probably the right trade-off compared with a session that stays stuck, but a visible notice may be worth a follow-up.
This overlaps closely with #53108, which takes the same approach for the same issue and now has merge conflicts with dev.
Issue for this PR
Closes #53107. Related: #53108 (earlier PR for the same issue).
Type of change
What does this PR do?
HTTP 413 payload rejections currently leave long sessions resending the same oversized history. Route these failures through the existing one-shot compaction recovery before assistant output starts. Recovery summaries omit inline media without unnecessarily reducing the token budget; original messages and images remain stored. Automatic-compaction opt-out and the existing recovery limit still apply.
This is an independent implementation against current
dev.How did you verify your code works?
bun run checkand corebun run typecheck:tscpass.dev.devwith macOS/bin/bash3.2.To reproduce the focused coverage: from
packages/core, runbun run script/test.ts test/session-runner.test.ts test/session-step.test.ts test/session-compaction.test.ts test/session-native-compaction.test.ts.Visual
Screenshots / recordings
No UI changes; verified with deterministic runner fixtures.
Checklist
Added by the opencode bot (AI-generated).
Related: #48095, #52042