Repository navigation
Stop provisioning retries from doubling their input - #6882
Merged
Merged
Conversation
A retry re-sends the failed turn's input with every block marked agent-only. The send path then treated that request as an undelivered first turn and prepended its leading agent-only blocks, so each retry of a turn that never started carried two copies of the previous one. Retries now skip the deferred first-turn context: the input they re-send already contains it. Retries that reprovision a workspace, or restart an interrupted startup, also dropped their retry marker, so every failure reported attempt 1 and a retry policy's attempt limit never applied. Both paths now record retryOf on the turn request. Fixes #6558 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
A retry re-sends the failed turn's input with every block marked
agent-only. The send path then reads that request throughresolveDeferredFirstTurnContext(the side-chat anchor carry-over from #2403): the last request is aturn/starton anerrorthread that never reachedturn/started, so its leading agent-only blocks — the entire retried message — were prepended to the new retry. Each retry of a never-started turn therefore carried two copies of the previous one. Separately, a retry that had to reprovision the workspace (or restart an interrupted startup) dropped itsretryOfmarker, so every failure reportedattemptNumber: 1and a retry policy's backoff and attempt cap never applied. Together these let a failing provisioning loop grow the stored input exponentially (994 B → 337.5 MB in #6558) intostartup_context.What changed
thread-send.ts: a dispatch carryingretryOfskips the deferred first-turn context. The retry re-sends the failed request's full input, which already contains that context.thread-turn-dispatch.ts,thread-provisioning.ts,dispatch-attempt.ts:retryOfis threaded throughdispatchTurnDuringReprovision→requestThreadTargetReprovisionand throughadmitPendingThread→requestThreadProvision, so the turn request those paths append recordsretryOfRequestId/retryAttemptlike the ready-environment path already did.Not in this PR: the issue's other two suggestions (leaving
startup_contextout of thread-list queries, flagging oversized stored context). They are defence in depth against large first prompts in general and touch theThreadRowshape every list caller uses, so they belong in a separate change.How you verified
New tests in
apps/server/test/threads/turn-failed-retry.test.ts; both fail onmainand pass here:retryAttempt2…6 (onmainthe input block count goes 1, 2, 4, 8, 16, 32);error(the Provisioning retry doubles the turn input; the copy lands in startup_context and every thread list loads it (0.48.0) #6558 reprovision path) recordsretryAttempt: 3and stores one copy of the input instartup_context(onmainit records noretryAttempt).pnpm exec turbo run typecheck lint --filter=@bb/serverpasses.pnpm exec turbo run test --filter=@bb/server: 3855 passed, 1 failed (public-thread-timeline-push.test.ts, unrelated; passes twice in isolation).Live check with each checkout's source
bbCLI againstpnpm start:worktreeservers formainand this branch. The fixture is a worktree thread whose.bb-env-setup.shalways exits 1, so every provisioning attempt fails, thenbb thread retry× 6:retryAttemptretryAttemptThe queued retry card reads "attempt 2" on main after 7 failures and "attempt 8" on this branch. A normal claude-code turn and a follow-up still complete on the branch server.
Fixes #6558
🤖 Generated with Claude Code