Repository navigation
fix(agents): corrections sent during recovery compaction never reach the model - #185381
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesAllows corrections committed by the active attempt to reach subsequent model calls after recovery compaction. Example: A user sends “Correction sent during compaction.” while recovery compaction is running.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current correction-delivery regression, preserves unrelated input exclusion, and has no definite introduced correctness finding. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe embedded runner prepares session history before provider conversion; pending-input custody identifies foreign inputs, and session events identify inputs consumed by the active attempt. flowchart LR
A[Accepted correction] --> B[Steering admission]
B --> C[Active session commit]
C --> D[Attempt adoption set]
E[Foreign input snapshot] --> F[Model context filter]
D --> F
F --> G[Provider request]
Technical reviewBest possible solution: Retain per-input adoption in the existing attempt filter while preserving exclusion of unrelated live inputs. Do we have a high-confidence way to reproduce the issue? The unconditional main-branch filter explains the failure, and the linked Gateway scenario reports matching baseline and revert results; this read-only review executed no target code. Is this the best way to solve the issue? The change narrowly updates the existing filter using session-owned consumption events, with a distinct negative control protecting the original announcement-isolation contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dee511a5cc0e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +21, Tests +76. Total +97 across 6 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 26, 2026, 11:41 PM ET / October 27, 2026, 03:41 UTC. |
Retain the landed preparation adoption owner from #185381 rather than a competing identity-marker exception. Keep the distinct startup regression and preserve upstream Gateway diagnostics. Co-authored-by: steipete <[email protected]>
Related: #163655, #178985
What Problem This Solves
Fixes: a correction the user sends while a run is doing recovery compaction is accepted (
chat.sendreturnsstarted) but never reaches the model, so the run answers without it.User Impact
Corrections and follow-up messages steered into a run that hits context overflow and compacts are delivered to that run again, as they were before #163655.
Why This Change Was Made
#163655 hides other turns' live pending inputs from an attempt's model context so announcement runs don't answer a queued chat turn. It samples those inputs once at the attempt boundary and filters them from every later model call. Recovery compaction starts a new attempt while the correction is still live custody, so the correction is sampled as foreign; when
chat.sendthen steers it into that attempt, the agent loop commits it but the frozen filter keeps stripping it.The attempt's foreign-input filter now treats a user input as its own once this attempt commits it (
message_end). Adoption is per idempotency key: inputs the attempt never commits, such as another queued turn, stay hidden. The listener is scoped to the attempt's session and goes away with it.Accepted edge case: adoption lives for one attempt. If a second recovery attempt starts in the same run before the correction's pending-input owner settles, that boundary could sample it as foreign again. I did not reproduce this; the steering e2e settles the owner (
pendingInputs.totalis 0). An owner-level handoff (linking the steered input to the run, likepromotedOwner) would cover it but needs the Gateway steering path to reach pending-input custody; this keeps the fix inside the existing boundary owner.Evidence
test/e2e/qa-lab/runtime/gateway-session-steering*.e2e.test.ts, run locally, not committed here): "delivers a correction sent during recovery compaction to the same run once" fails onmainwith terminal replyNever received: Correction sent during compaction.; passes with this change. All 12 cases in both steering e2e files pass.attempt-session-boundary.live-input.test.ts: a live input steered into the run after the boundary sampled it reaches the next model call, while another turn's live input stays hidden. Red on base, green here.attempt-session-boundary.live-input/.preparation/.orphan/attempt-session-boundary,attempt-session-runtime-context,attempt-session-replay,session-manager-async-message(-custody),session-accessor.pending-inputs*/pending-input-mirror-replay.pnpm check:changedpasses (dead-export scan skipped locally; it flags pre-existingextensions/codexexports unrelated to this diff).tsconfig.jsonlibES2024 because of an unrelatedPromise.withResolversdeclaration-build failure onmain; that change is not included.