Skip to content

feat(runtime): compact on a provider window rejection and admit exhausted prompts from the summary alone (RR6) - #126

Merged
lg2m merged 1 commit into
docs/rr-linear-linkagefrom
feat/eng-868-rr6-reactive-overflow
Sep 22, 2026
Merged

lg2m merged 1 commit into
docs/rr-linear-linkagefrom
feat/eng-868-rr6-reactive-overflow

Conversation

@lg2m

@lg2m lg2m commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

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 per workflow.md § 4 (touches sessions/).

Behaviour

Two ways a session could still wedge after in-run compaction shipped in #92:

  1. 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_exceeded on the first rejection and the next prompt inherited the known-overflow basis. Now a ContextExceeded stream 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.

  2. 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 by SUMMARY_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

  • New informational RuntimeEvent::ProviderOverflow (not on the wire) clears the measured occupancy basis. Store::latest_compaction_summary added. No schema or protocol change.
  • The known-overflow basis check is skipped for the downgraded shape: the shape-level basis is deliberately byte-independent, so it cannot distinguish the smaller request from the rejected one.
  • Direct qq ask runs (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.
  • Five fixtures that asserted the old "exhausted → refuse" policy now assert summary-only admission (a_bounded_step_that_fails… now ends with the provider's own ProviderContextExceeded after the downgraded request is also rejected).
  • New harness script ShellRepeatedlyWithProviderOverflow.
  • cargo test -p qq-core --lib 692 green on a clean run; workspace clippy -D warnings and 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.

…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
lg2m added this pull request to stack #129 September 22, 2026 15:39
@lg2m
lg2m merged commit bee52a1 into main Sep 22, 2026
4 checks passed
@lg2m
lg2m deleted the feat/eng-868-rr6-reactive-overflow branch September 22, 2026 16:48
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant