Repository navigation
fix(turn): surface context-overflow recovery and warn when the window is unknown - #496
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What (description of the change)
Context-window visibility and overflow recovery for the compaction feature (#440):
tole doctor --tier catalogprints a non-fatal!warning ("set TOLE_CONTEXT_WINDOW=") when the configured model is served but neither the setting nor/modelsprovides a window; a pass line when it does. Exit code and coverage ledger unchanged. (run_cligains aconfigured_windowargument;diagnoseunchanged.)compaction::is_context_overflowclassifies a provider error as context overflow only when the HTTP status is 400/413/422 AND the error text carries one of five phrasings (context_length_exceeded, "maximum context length", "context length exceeded", "exceeds the context window", "prompt is too long"). After a failover only the last provider's error counts.fact/context_overflowregister in the same commit that settles the failed turn;Compactor::before_turnthen forces one compaction pass on the nextresume/chatregardless of window or threshold, and clears the flag. No other provider failure writes the flag.--no-compactiondisables the recovery pass (flag stays set); a failed summary call keeps the flag; a pass with nothing to summarize clears it with a note.report_outcome/chatfailure lines append "(compaction will run on the next resume)" on overflow.TOLE_CONTEXT_WINDOWrow, doctor table, the single-turn-too-big limit),docs/epics.md,docs/threat-model.md. CHANGELOG under [Unreleased].Why (the problem you're solving)
Closes #481 (approved scope: items 1-3). On the fleet gateway
/modelscarries no window field, so compaction was silently off with one stderr hint; and a context overflow ended the turn with no recovery path. Owner decision 3 Nov 2026: a mid-turn overflow ends the turn with the provider's message and a hint, and the next prompt compacts first — compaction stays between-turns; NO compact-and-retry-in-place. Item 4 (built-in window table + 24 h disk cache) is deferred as a possible follow-up.Testing (how you verified this works)
overflow_pending,diagnose_with_windowabsent). GREEN: corecompaction11/11, clicompaction_host+doctor25/25.compaction_e2e, 5 passed): provider answers HTTP 400 overflow once -> rc 4 with the provider message + hint, no summary call or retry in the failed turn, flag durable in the session file; the next resume compacts and succeeds; a further resume does not compact again. Doctor E2E: warning with no window, pass line with one.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --no-fail-fast(963 passed / 0 failed, 55 binaries),cargo test -p tole-core --no-default-features(383 passed / 0 failed),cargo build -p tole-cli --no-default-features: all pass. cora pre-commit gave a real verdict: "No issues found".keep_turns=1) — a single turn bigger than the window cannot be fixed by compaction (README says so). Theserve/ACP failure lines show the provider message without the hint (still set the flag and recover on the next prompt); left alone to avoid scope creep. Not run: perf test, live-gateway check.