Agent pane: a chat that outgrew its context window offers Compact, not a Retry that fails again
First of the sustained-chat error-recovery dead ends (claim: "inventorying and fixing the top five cmux NEXT sustained-chat error recovery dead ends, starting with findings and turn retry/continue UX").
The dead end
A long chat that reaches the model's context window fails with Claude's prompt is too long, OpenAI's context_length_exceeded / "maximum context length", or Codex's "exceeds the context window". In the pane:
failureKindmatched none of these, so the card read "Claude Code ran into a problem and stopped."- Retry was the only way out, and it sends the same prompt into the same history, so it fails the same way.
- acpmux never auto-resumes a refused request (
turn_errors.rs,limits_sign_in_bad_requests_and_refusals_are_never_continued), and the composer's context card has a Compact slot that nothing wires (ContextRingonCompacthas no caller).
The person had to know to type /compact themselves. Long chats hit this by definition.
Change
failureCopy.ts: a newcontext-fullkind, from the text or from a typederrorCodethat names the context (Codex'scontext_window_exceeded). It is checked before capacity; a per-minute "too many tokens" limit staysrate-limited.failureRecoveryreturns"compact"for it, and the copy reads: "This chat is too long for {harness}'s context window. Compact it, then retry."TurnRows.tsxTurnFailure: a context-full card leads with Compact (filled), with Retry after it. One click sends one/compact: the button is disabled until the send settles.turnActions.ts/App.tsx:compactsends/compactthroughchat.send, exactly as Continue sends its prompt, so it shows as the reader's prompt and queues behind one already sent. It has the same reach checks as Continue and Restart (restartOwner/restartReaches), so it never goes to a View Only chat, a read-only pane, or the next chat during a switch.- Compact is offered only where the agent lists
compactin itsavailable_commands_update(offersCompact). Elsewhere, Retry stays the way out. - One new string,
turn.failure.contextFull, in all 21 pane locales (non-Englishneeds_review). The button reusescontext.compact.
Tests
webviews/test/turn-error-card.test.tsx, 4 new tests:
- context-full classification from five real error texts and from the typed code. A per-minute token limit stays capacity.
- The card's order: Compact (primary), then Retry. A double click sends once.
- Without
/compact, Retry stays primary. offersCompactonly for the agent's own command.
Red at 64e5e7e6b3b (test only, base sources): 3 fail (the fallback test passes on base, as it should). Green at 850946c5538: bun test test/turn-error-card.test.tsx test/failure-copy-team-account.test.ts, 25 pass, 0 fail.
Observed / Not run
- Observed:
- The red and green runs above.
vp lintexit 0,vp check --no-fmt --no-lintno type errors,vp fmt --checkclean on the changed files,check:catalog-keysclean,prepush-gate.pyno new violations.scripts/web-lint.sh's only red isvp fmt --checkonsrc/pages/settings/channelsCard.test.tsxandsrc/pages/settings/store.ts. This PR doesn't touch those; it is a base finding.
- Not run:
- A live agent hitting a real context overflow. This was checked against the error texts acpmux's own tests use and the published OpenAI and Codex wordings.
- The gallery compare page: this lane host is not a fleet origin, so
gallery-compare.shcan't reach the gallery host. The before/after comes from this PR's gallery advisory run (agent-pane.turn-error-card:context-full,context-full-no-compact; the base has no such state, so "before" is theunknownvariant's generic card).
Risk
Low. The change is limited to the failed-turn card of one failure kind. Compact sends the harness's own slash command through the existing send path, and only where the harness offers it.
Changelog
Fixed: when a long agent chat runs out of context, its error says so and offers Compact instead of a Retry that fails again.
Agent session: agent session
š¤ Generated with Claude Code
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.