Skip to content

Stop provisioning retries from doubling their input - #6882

Merged
ymichael merged 1 commit into
mainfrom
bb/triage-and-resolve-issue-6558-thr_em9x95uue9
Nov 3, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/triage-and-resolve-issue-6558-thr_em9x95uue9

Conversation

@ymichael

@ymichael ymichael commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

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 through resolveDeferredFirstTurnContext (the side-chat anchor carry-over from #2403): the last request is a turn/start on an error thread that never reached turn/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 its retryOf marker, so every failure reported attemptNumber: 1 and 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) into startup_context.

What changed

  • thread-send.ts: a dispatch carrying retryOf skips 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: retryOf is threaded through dispatchTurnDuringReprovision → requestThreadTargetReprovision and through admitPendingThread → requestThreadProvision, so the turn request those paths append records retryOfRequestId/retryAttempt like the ready-environment path already did.
  • No wire, CLI, or schema changes.

Not in this PR: the issue's other two suggestions (leaving startup_context out of thread-list queries, flagging oversized stored context). They are defence in depth against large first prompts in general and touch the ThreadRow shape 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 on main and pass here:

  • pnpm exec turbo run typecheck lint --filter=@bb/server passes.

  • 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 bb CLI against pnpm start:worktree servers for main and this branch. The fixture is a worktree thread whose .bb-env-setup.sh always exits 1, so every provisioning attempt fails, then bb thread retry × 6:

    Retry main: input bytes / retryAttempt branch: input bytes / retryAttempt
    1 104 / missing 104 / 2
    2 208 / missing 104 / 3
    3 416 / missing 104 / 4
    4 832 / missing 104 / 5
    5 1,664 / missing 104 / 6
    6 3,328 / missing 104 / 7

    The 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

AGENT GENERATED

🤖 Generated with Claude Code

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]>
@ymichael
ymichael merged commit f614d00 into main Nov 3, 2026
31 checks passed
@ymichael
ymichael deleted the bb/triage-and-resolve-issue-6558-thr_em9x95uue9 branch November 3, 2026 00:21
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.

Provisioning retry doubles the turn input; the copy lands in startup_context and every thread list loads it (0.48.0)

1 participant