Repository navigation
feat(runtime): compact on a provider window rejection and admit exhausted prompts from the summary alone (RR6) - #126
Merged
Conversation
…sted prompts from the summary alone (RR6) Two ways a session could still wedge after in-run compaction shipped (#92). First, the estimate is provider-neutral and 30-40 % high or low on real transcripts; when it said a request fit and the provider said it did not, the run failed with provider_context_exceeded on the first such rejection and the next prompt inherited the known-overflow basis. Second, once the between-run fold had spent its steps and the retained transcript still did not fit, admission refused every later prompt with "automatic compaction ran N summarizer steps ... start a new session" (9 runs, 3 sessions wedged in the audit). The provider's verdict now overrides the estimate in both directions. In the run loop, a ContextExceeded stream error before anything streamed, on a run with a compactor and a compaction boundary, re-plans the turn once with in-run compaction forced and re-issues it; a second rejection of the same turn fails as before. At admission, an Exhausted(Attempted) rejection, or a known-overflow repeat the fold cannot help, no longer fails the prompt: the run starts once from the latest between-run summary alone, opened by a notice, and the planner judges that smaller request on its own. Nothing is deleted; the next prompt reassembles from the store as usual. New informational RuntimeEvent::ProviderOverflow (not published) clears the measured occupancy basis. Store gains latest_compaction_summary. No schema or protocol change. Tests: a_provider_window_rejection_compacts_the_run_and_continues (scripted 413 under a 200k window: one in-run compaction, 12 calls once, next prompt normal); an_exhausted_fold_admits_the_prompt_with_summary_only_history (step one commits, prompt rejected, step two rejected, retry runs from the summary with every row retained). Five fixtures that asserted the old refusal now assert summary-only admission. Closes ENG-868.
lg2m
added a commit
that referenced
this pull request
Sep 22, 2026
…rotocol 27 Protocol 26 was claimed by #120 (turn recovery, ADR-0040) while #122 was open, so the effort pin moves to protocol 27. v26/ goldens are #120's; v27/ is regenerated from them plus command_set_session_effort and receipt_session_effort_set. Harbor trace fixtures bump 26 -> 27. Store schema stays 34 (main is on 33). MAX_TURN_RETRIES kept. Also picks up #126-#128 (RR6, RR7, onboarding); no overlap. Verified on the identical tree as a rebase: cargo test --workspace, fmt --check, clippy -D warnings all green.
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.
Stacked on #124 (Linear linkage, docs only). RR6 of
docs/plans/run-reliability.md; audit finding R02 (b)+(c). Closes ENG-868. Independent review requested perworkflow.md§ 4 (touchessessions/).Behaviour
Two ways a session could still wedge after in-run compaction shipped in #92:
The estimate and the provider disagree. When the provider-neutral estimate said a request fit and the provider said it did not, the run failed with
provider_context_exceededon the first rejection and the next prompt inherited the known-overflow basis. Now aContextExceededstream error before anything streamed — on a run with a compactor and turns to compact — re-plans the turn once with in-run compaction forced and re-issues it. A second rejection of the same turn fails as before.The fold is exhausted. Once between-run compaction had spent its steps and the retained transcript still did not fit, admission refused every later prompt ("automatic compaction ran N summarizer steps … start a new session"; 9 runs, 3 sessions wedged). Now an
Exhausted(Attempted)rejection — or a known-overflow repeat the fold cannot help — starts the run once from the latest between-run summary alone, opened bySUMMARY_ONLY_NOTICE, and the planner judges that smaller request on its own. Nothing is deleted; the next prompt reassembles from the store as usual.Plan principle 5: admission may downgrade a prompt's context; it may not refuse it because an earlier run overflowed.
Design notes
RuntimeEvent::ProviderOverflow(not on the wire) clears the measured occupancy basis.Store::latest_compaction_summaryadded. No schema or protocol change.qq askruns (no compactor) are unchanged.Verification
a_provider_window_rejection_compacts_the_run_and_continues: scripted 413 at 7 results under a 200k window → exactly one in-run compaction, all 12 shell calls durable once, next prompt admitted normally.an_exhausted_fold_admits_the_prompt_with_summary_only_history: step one commits, prompt rejected, step two rejected → retry runs from the summary + notice, four prompts still in the store.a_bounded_step_that_fails…now ends with the provider's ownProviderContextExceededafter the downgraded request is also rejected).ShellRepeatedlyWithProviderOverflow.cargo test -p qq-core --lib692 green on a clean run; workspace clippy-D warningsand fmt clean. (Two deadline/delegation tests are timing-sensitive under full-workspace parallel load and pass in isolation and in their module groups — pre-existing, unrelated.)Docs
architecture.md§ run loop step 3; audit R02 status; ledger entry.