Repository navigation
Conversation
# Conflicts: # apps/server/src/services/prompt-history.ts # apps/server/test/public/public-thread-fork.test.ts # apps/server/test/services/prompt-history.test.ts # packages/host-daemon-contract/src/protocol.ts # packages/host-daemon-contract/test/contract.test.ts
ymichael
added a commit
that referenced
this pull request
Nov 3, 2026
## 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: - five consecutive retries of a never-started turn each re-send the original input once with `retryAttempt` 2…6 (on `main` the input block count goes 1, 2, 4, 8, 16, 32); - a retry against a provider environment in `error` (the #6558 reprovision path) records `retryAttempt: 3` and stores one copy of the input in `startup_context` (on `main` it records no `retryAttempt`). - `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](https://claude.com/claude-code) 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.
What was wrong
Side-chat forks persisted the selected-message reply anchor as agent-only input, but deliberately started the native provider fork with empty input so it remained idle. The first real send built its provider command only from the new message, leaving the anchor out of the first provider turn. This affected Codex, Claude Code, and Pi before provider-specific translation. See #2316.
What changed
turn/startedexists; later turns never receive it again.thread.start.input.HOST_DAEMON_PROTOCOL_VERSIONto 168 becauseturn.submit.inputsemantics change. The wire shape and database schema are unchanged.How you verified
The deterministic first-turn assertion failed on
mainbefore the fix: expected[seed, firstReply], received only[firstReply].pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-fork.test.ts test/services/prompt-history.test.ts— 29 tests passed.pnpm exec turbo run test --filter=bb-plugin-side-chat— 25 tests passed.pnpm exec turbo run test --filter=@bb/host-daemon-contract -- test/contract.test.ts— 37 tests passed.pnpm exec turbo run typecheck --filter=@bb/server --filter=bb-plugin-side-chat --filter=@bb/db --filter=@bb/host-daemon-contract— 8 Turbo tasks passed.Fixes #2316