Repository navigation
Fail runs whose provider turn never starts after a 5-minute deadline - #6736
Merged
ymichael merged 3 commits intoNov 3, 2026
Merged
Conversation
ymichael
added a commit
that referenced
this pull request
Nov 2, 2026
## Human comments
## What was wrong
After a server restart, the GitHub PR Status plugin restores each
environment's PR from its database and serves it right away. It also
starts a background re-check right away, often before the host daemon
has reconnected. That re-check returned `unavailable` ("machine isn't
available"), and `store.load` replaced the environment's known PR link
with that result. The sidebar row badge disappeared and stayed gone
until something re-read that row, such as opening the thread or
refocusing the page. Observed on prod: the server restarted at 13:04:14
and the daemon reconnected at 13:04:20. Afterwards the sidebar showed
only #6849 (the thread that was opened). Six other inbox threads with
open PRs (#6760, #6755, #6736, #6728, #6727, #6734) showed no badge,
although their links and snapshots were still in the plugin database.
## What changed
- `plugins/github-pr-status/store.ts`: when a re-check of a known PR URL
comes back `unavailable`, the environment's link is no longer replaced,
so the last snapshot keeps being served. The snapshot's `fetchedAt` is
still bumped, so the regular poll retries it. Discovery reads (no known
URL) behave as before.
- Behaviour change: `bb pull-request show` for an environment whose
machine is offline now prints the last PR bb saw, or `unavailable` when
it has none. Actions (`ready`/`draft`/`merge`) still refuse with the
machine message. The skill doc and README are updated.
## How you verified
- New store test, "keeps serving a restored PR when its machine is
unreachable after a restart": it restores a persisted PR, makes the
first re-check return `unavailable`, and checks that the PR is still
served, nothing is published, and the next successful check publishes
the update. It fails without the fix (`expected { outcome: 'unavailable'
} to deeply equal { outcome: 'available' }`) and passes with it.
- `pnpm exec turbo run test typecheck lint
--filter=bb-plugin-bb--github-pr-status`: 183/183 tests pass, typecheck
and lint clean.
> AGENT GENERATED
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/deadline-for-turns-that-never-start-4363-thr_y893gtvk47
branch
from
November 2, 2026 22:48
e5519e8 to
d082344
Compare
A provider can accept a turn request and never start the turn. The daemon's 2-minute watchdog only posts provider_turn_start_timeout, so the thread stayed active forever and later messages queued behind "Waiting for turn to start" (#4363). A periodic sweep now finds active threads whose status has not changed for TURN_START_DEADLINE_MS, with no turn/completed inside that window, no active turn, and a connected host daemon. It appends a provider_turn_start_deadline system/error and requests a stop with the provider-turn-idle interruption reason, so the run fails into error and Retry or a new message sends again. threads.status_changed_at records when the status last changed, so renames, read state and section moves do not postpone the deadline. The migration backfills it from updated_at. Refs #4363 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/deadline-for-turns-that-never-start-4363-thr_y893gtvk47
branch
from
November 3, 2026 00:09
d082344 to
db91783
Compare
…deadline The hub reports a daemon as connected as soon as its socket opens, before the daemon replays events it buffered while disconnected. A run whose turn started while the host was away could look like it never started during that window, and the sweep would stop it. The hub now records when each daemon session connected, and the sweep skips hosts whose daemon connected less than TURN_START_DEADLINE_RECONNECT_GRACE_MS (one minute) ago. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/deadline-for-turns-that-never-start-4363-thr_y893gtvk47
branch
November 3, 2026 18:27
This was referenced Nov 3, 2026
ymichael
added a commit
that referenced
this pull request
Nov 4, 2026
…iled (#7001) ## Human comments ## What was wrong A steer sent while a turn is starting is parked in the queue as `turn-starting`. If the provider never starts that turn, the run fails: Codex's `turn/start` times out, or the 5-minute turn-start deadline from #6736 fires. The thread then goes to `error`. The parked row correctly stays queued. It goes out with the next turn, which starts either when the user sends another message or when the provider recovers and starts the turn that timed out. But `describeQueuedMessageWait` chose the row's label from `waitingOn` alone, so on the errored thread it kept saying "Waiting for turn to start" after that start had already failed. ## What changed - `apps/app/src/lib/queued-message-wait.ts`: the label function now takes the thread status. On an errored thread, a `turn-starting` row reads "Turn didn't start · sends on the next turn". This covers both ways the next turn can start, and it fits the collapsed queue header at 390 px without truncation. The label is unchanged in every other state. - `QueuedMessagesList` and `LazyQueuedMessagesList` pass `threadStatus` to the row wait line and to the collapsed header's wait line. - `ThreadDetailPromptArea` passes `thread.status` and adds it to the memo dependencies, so the label changes while the thread is open, without a reload. This is app-only: no wire, protocol, CLI or SDK changes. ## How you verified **Live, `pnpm start:worktree` with real Codex.** I froze the thread's `codex app-server` with `kill -STOP <pid>`, sent one message (`turn/start` hangs), then a second (parked as `turn-starting`). After 30 s the `turn/start` request timed out (`JSON-RPC request timed out: turn/start`) and the thread went to `error` with the second message still queued. I ran the same steps on `origin/main` and on this branch, both against the same data dir, in light mode. - **Before (main):** the errored thread's queue row still says "Waiting for turn to start". - **After (this branch):** the page stayed open from the active state through the error, with no reload. The row changed from "Waiting for turn to start" to "Turn didn't start · sends on the next turn". After `kill -CONT <pid>`, Codex started the timed-out turn with no new message, and the parked steer joined it, was answered, and left the queue empty. The first version of this branch said "sends with your next message". Two things showed that was wrong: the text was cut off in the 390 px header, and on resume the steer went out about 4 s before my next message. | | Desktop (1440) | Phone (390) | |---|---|---| | Before | <img src="https://raw.githubusercontent.com/get-bb/bb/0af99528e46de25d95e8b6ac0a7a961a4049ed83/before-desktop.jpg" width="480"> | <img src="https://raw.githubusercontent.com/get-bb/bb/0af99528e46de25d95e8b6ac0a7a961a4049ed83/before-phone.jpg" width="200"> | | After | <img src="https://raw.githubusercontent.com/get-bb/bb/0af99528e46de25d95e8b6ac0a7a961a4049ed83/after-desktop.jpg" width="480"> | <img src="https://raw.githubusercontent.com/get-bb/bb/0af99528e46de25d95e8b6ac0a7a961a4049ed83/after-phone.jpg" width="200"> | **Tests:** `queued-message-wait.test.ts` has a new case for the errored `turn-starting` label, and the list tests were updated for the new prop. `vitest run` on `queued-message-wait.test.ts`, `QueuedMessagesList.test.tsx` and `LazyQueuedMessagesList.test.tsx` passes: 3 files, 87 tests. `pnpm exec turbo run typecheck --filter=@bb/app` passes. CI runs the full suites. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- 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 provider can accept a turn request and never start the turn (#4363: Claude Code,
client/turn/requestedwith noturn/startedafter it). The daemon notices: its watchdog fires after 2 minutes, but it only posts aprovider_turn_start_timeoutwarning and never clears or fails the pending start. Onlyturn/started,turn/completedor a non-retryingprovider/errorclear it. Nothing on the server ever ends the run, so the thread staysactive("Working…") forever. Follow-ups sent meanwhile are parked asturn-startingbecause the thread isactivewith no active turn, and that wait only clears once the thread is idle or has an active turn, so they never send.What changed
Turn start deadline (server). A new periodic sweep,
stopRunsWhoseTurnNeverStartedinapps/server/src/services/threads/thread-lifecycle.ts, is registered as theturn-start-deadlinejob inperiodic-sweeps.ts. It finds threads that meet all of these conditions:activeand not deleted;status_changed_atat leastTURN_START_DEADLINE_MS(5 minutes) old;turn/completedin that window;For each one it appends a
system/errorwith codeprovider_turn_start_deadlineand requests a stop with theprovider-turn-idleinterruption reason, which fails the run.threads.status_changed_at(db). A new column, set at the only two placesthreads.statuschanges: thread creation and lifecycle transitions. Migration0150_thread_status_changed_atwas generated with drizzle-kit and backfills the column fromupdated_at. Renames, read state, section moves and other metadata updates don't move it, so they don't postpone the deadline.No wire change. The interruption reason stays on the server;
thread.stopstill sends onlyenvironmentId,intentandthreadId.HOST_DAEMON_PROTOCOL_VERSIONand the plugin SDK are unchanged. No CLI, guide or doc surface is affected.Left as is. The 2-minute watchdog text ("stopping the thread interrupts it") is unchanged. It's still true, and naming the deadline would put a value the server decides into daemon text.
Visible behaviour changes
bb thread retryand the retry API resend the original input word for word, because the provider never accepted it.turn.failedevent carries no error category, so its policy declines it asnot-retryable.error, its row still reads "Waiting for turn to start"; that label predates this change and is left for a follow-up.TURN_START_DEADLINE_RECONNECT_GRACE_MS). The hub reports the daemon as connected as soon as its socket opens, before the daemon replays events it buffered while away, so a turn that started during the disconnect could otherwise look like it never started.How you verified
New tests:
apps/server/test/threads/turn-start-deadline.test.ts, which drives the realrunPeriodicSweepswith the clock moved forward.errorafter the deadline but not before; Retry resends the inputactive)turn/completedis left aloneThe three guard tests can't fail on main, since main never stops a thread. I removed each check from the code in turn: removing the active-turn,
turn/completedor daemon check failed exactly its own test, and switching toupdated_atfailed the metadata test.Migration test:
packages/db/test/migrate.test.ts"backfills each thread's status change time from its last update" fails without the backfillUPDATE. I added the new column to the helpers that rewind the schema for migration tests.Scratch checks (not committed):
turn.failedis announced once witherrorInfo: nullandinputAccepted: false.turn-startingis kept after the deadline, and "Send now" dispatches it.Live QA on
pnpm start:worktree: this PR and origin/main ran side by side, each with the same uncommitted fault patch. When a prompt contains a marker, Claude Code's bridge accepts the turn without delivering it, which is the Claude turn-start timeout leaves thread working and follow-up waiting #4363 shape.bb thread retryresent the same input.updated_at.Commands:
pnpm exec turbo run typecheck lint --filter='...[origin/main]': 11 of 11 tasks pass.pnpm exec turbo run test --filter=@bb/server --filter=@bb/db: db 653 passed; server 3859 passed, 1 skipped. The one failure, a 15 s timeout inplugin-native-server-loading.test.tsat load average 185, passes when run alone.oxfmtis clean on the changed files.Fixes #4363
🤖 Generated with Claude Code