Repository navigation
Conversation
…on turn A transient provider rejection that streamed no output after settled tools left the transcript unchanged, but recovery still activated the hidden continuation prompt. That appended an internal user turn per retry, shifted the runtime-context boundary, and invalidated the prompt-cache prefix on non-append-only routes. Replay the persisted keyed user turn in place for that case; keep the continuation prompt for partial output, uncertain tools, native harness threads, thrown prompt failures, internal prompts, and unkeyed turns.
|
🦞👀 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 changesThis PR replays persisted keyed user turns after transient provider failures with no output instead of adding a hidden continuation turn. Example: An embedded OpenAI Responses request receives HTTP 429 after completed tool work without producing output.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a remaining current-main prompt-history problem with a focused change; no concrete correctness or security defect was found, and the reviewed head has green CI. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded runner classifies failed attempts, selects recovery, and prepares the next session request from the durable transcript before provider dispatch. flowchart LR
A[User turn] --> B[Embedded runner]
B --> C[Provider request]
C --> D[Attempt recovery]
D --> E[Session prompt state]
E --> F[Keyed transcript replay]
F --> C
Technical reviewBest possible solution: Use the existing keyed replay owner for proven zero-output rejections while retaining continuation for partial output, uncertain tools, internal prompts, and native harnesses. Do we have a high-confidence way to reproduce the issue? Current-main source unconditionally activates continuation after accepted transient retries, and the supplied production log excerpt reports matching history rewrites; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch removes unnecessary turn creation through existing recovery and replay owners, with narrow eligibility checks and no new configuration or persistence format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1d0d6db70218. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +31, Tests +109. Total +140 across 5 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 24, 2026, 11:51 PM ET / October 25, 2026, 03:51 UTC. |
|
Landed on |
What Problem This Solves
Fixes: each rate-limit retry adds a hidden "Continue the current task…" user message, even when the provider rejected the request before producing any output.
User Impact
User impact: when a provider returns a rate limit (or another transient error) without streaming anything, the agent resends the same request instead of starting a new hidden turn. On OpenAI Responses routes this keeps the prompt cache intact across retries. Before, every retry re-sent a prompt that missed the cache from the rewritten message onward; a live session re-sent ~100k uncached input tokens per retry. Transcripts also stop accumulating empty-error + hidden "Continue…" pairs, five of which appeared in one live session in two minutes.
Why This Change Was Made
Transient-failure recovery (#139397) always resumes through the hidden continuation prompt, because replaying the original request after tools ran could repeat their work. That prompt is still right when output was partly produced or a tool's outcome is uncertain. A rejection with no output, after every tool has settled, leaves the transcript exactly as it was before the request. In that case the persisted user turn (matched by its idempotency key) is replayed in place.
AgentSession.prompt()already supports this without appending a message, and the LLM boundary drops the empty error turn.The hidden prompt remains for: partial output, unsettled or async tools, thrown prompt failures, native harness threads (
pluginHarnessOwnsTransport), active internal prompts, and user turns without a persisted idempotency key.Evidence
cache read dropped 141511 -> 32925 … runtimeContextCarrier(runtimeContextCarrier changed provider history), historyRewrite(message 276 (user) differs from the previous request …)followed eachrate_limit_exceeded type=tokensretry. The transcript showsassistant(error, content: [])+ hiddenuser"Continue the current task…" per retry.attempt-session-replay.test.ts(real session boundary + persisted transcript): after completed tools, a rate-limited request with no output is retried across a rebuilt session. The resent request equals the rejected one. Only the regenerated tail runtime context differs on the non-append-only route. Exactly one user row remains.attempt-recovery.test.ts: eligibility matrix (no output after settled tools / before work → replay; partial reasoning, native harness, active lifecycle item, thrown prompt failure → continuation). The two replay cases fail on the previousattempt-recovery.ts.run.session-prompt-state.test.ts: replay only for a persisted keyed operator turn; unkeyed, unpersisted, and internal prompts keep the continuation.pnpm test <file> --maxWorkers=1:attempt-recovery.test.ts134 passed;run.session-prompt-state.test.ts20 passed;attempt-session-replay.test.ts52 passed (171s wall for the file; the two new boundary cases take ~2.9s each because they open the real agent database, the only layer that proves the request bytes across a rebuilt attempt).pnpm check:changed: format, lint, core and test typecheck pass. The dead-export scan fails only on untouchedscripts/exports that are already present onmain.