Repository navigation
Description
What happened
When a main model request is rejected as too long and it produced no output, the Host sends a summary request. If that summary request fails, the turn fails, the history stays as it was, and every later turn in the conversation repeats the same sequence: main request overflows, summary request, failure. The conversation cannot be used again until the user changes the model or its context window, or starts a new conversation. Each failed turn also adds a "[Host] This turn failed and ended here" note to the next request, so the history only grows; the model never reads the note because that request overflows too.
A summary request sent after an overflow has no main request to fall back to (the main request was already attempted, plugins/agent/state/src/store/fallback.rs), so every way the summary can fail ends the turn:
| Summary request | Turn | What the user sees |
|---|---|---|
| Overflows too | failed | Maka could not continue this turn: invalid event transition: context overflow requires an original interrupted model attempt |
Cut off (finish_reason: length) |
failed | summary_has_invalid_finish_reason |
| Refused with a 4xx | failed | model HTTP request failed (status 400): … |
Withheld (content_filter) |
failed | provider failed (Withheld): … |
The first row is a second defect on top: the summary's own overflow is assessed like a main request's, a ContextOverflow recovery is recorded on an attempt that was closed (not interrupted), and fold rejects it. The user gets an internal state-transition error where the cause is "the summary request was also too long".
Why the summary overflows in practice
The summary input is trimmed only when its estimate exceeds summary_budget (96% of the configured window, plugins/agent/engine/src/context_input.rs). A main request that overflows with no output had an estimate below the compaction threshold, or it would have been compacted before it was sent. So the summary input is not trimmed, and it is the same history plus the same tool definitions plus the summary instructions: larger than the request that just overflowed. Nothing retries with a smaller input.
That is the case whenever the real window is smaller than the configured one: a custom or relay connection with a window set too high, a local server (Ollama, LM Studio, vLLM) whose num_ctx is below the declared value, or a model with no input limit, where proactive compaction never triggers and the summary budget defaults to 200k.
How to reproduce
A test on rust-preview 871e747 drives it with the fixture model: one normal turn, then five turns in which the main request returns HTTP 400 "maximum context length is 8192 tokens" and the summary request fails in each of the ways above. Every turn sends the unchanged history, sends one summary request, sends nothing after the summary fails, and ends as failed.
failed_overflow_summary_makes_every_later_turn_fail in plugins/agent/native/src/owner/driver/tests/model_recovery/preset_acceptance.rs; I can push the branch if useful.
Not tested: an overflow reported after the stream started, and manual compaction (by reading, it uses the same budget and should fail the same way).
Direction
- A summary request that overflows should not record a
ContextOverflowrecovery; it should end as a plain failure that says the summary was too long. - When the summary fails after an overflow, retry it once with a smaller input, bounded by the size that actually overflowed (for example half of the overflowing request's estimate) instead of the configured window. This needs no new durable fact.
- If that also fails, the turn fails as today. Cutting history without a summary is a design change and is not part of this.
I will open a PR for 1 and 2 unless you would rather handle it in the compaction work you have in progress, @M4n5ter.
Found by reading the failure paths and confirmed with the test above. Investigation and text by Claude Code (Claude Fable 5.2, with a Claude Opus 5.5 subagent writing the reproduction).
Activity
UncertaintyDeterminesYou4ndMe commentedon Nov 21, 2026
PR for directions 1 and 2: #7113.
A related race, not fixed there:
context_overflow_after_partial_output_compacts_and_continues(from #7055) fails intermittently on plainrust-preview871e747 — 3 of 10 fullmaka-agent-nativelib runs on macOS, never when run alone. Each failure logsand the test then times out. No summary overflows in that test, so here the
ContextOverflowrecovery is recorded for a main attempt thatfolddoes not yet see as interrupted. My reading, not verified:reconcilecan pickAssessfor an attempt whose model work has ended with the overflow error before the interruption is written, since theAssesscheck comes before theInterruptone and only requires "no recovery, not closed successfully". Under load a real overflow would then fail the turn with this internal text instead of compacting.cell_notifications_deduplicate_child_knowledge_per_step_cutis also intermittent on the same commit (4 of 6 full runs, "missing notification burst-note-N in step 2"); I have not looked into it.(Claude Code, Claude Fable 5.2.)
fix(agent): summarize an overflowed request from less than what overf…
fix(agent): summarize an overflowed request from less than what overf…
fix(agent): summarize an overflowed request from less than what overf…
fix(agent): compact an overflow whose interruption was not recorded
fix(agent): compact an overflow whose interruption was not recorded
fix(agent): compact an overflow whose interruption was not recorded (#…