Repository navigation
Description
Summary
thread/resume is the only session-construction command that does not pass an explicit deadline to sendCommand, so it inherits the JSON-RPC transport default of 30 seconds. A resume answers only after the provider has built or loaded the thread's session, so on a large session the call dies at 30.0s and the thread is marked failed:
Command turn.submit failed
JSON-RPC request timed out: thread/resume
thread/start and thread/fork already use threadCreationRequestTimeoutMs for the same class of work. Resume needs the same deadline, or it needs the deadline to be a property of the command rather than an argument each call site remembers to pass.
Impact
A heavyweight pi thread becomes unusable: every new message fails during resume, the thread goes to error, and resending produces the same failure because nothing changed in between. Two consecutive attempts failed identically 90 seconds apart, with no provider crash and no error from the provider itself.
Reproduction
Observed on a self-hosted bb 0.45.0 instance, pi provider, thread thr_pbsqhhv4c8.
Session: 26.9 MB, 4366 records, 12 compactions (5.6 MB of summaries), ~108k tokens of live context.
Timeline from the thread's event log and the pi session file:
21:34:27.615Z client/turn/requested (resume needed, worker had idle-stopped)
21:35:01.215Z pi session records state/reconstructed <- construction finished
21:35:02.614Z client/turn/rejected: JSON-RPC request timed out: thread/resume
21:35:02.618Z system/error: Command turn.submit failed
21:36:01.500Z retry
21:36:32.747Z pi session records state/reconstructed
21:36:34.110Z client/turn/rejected: JSON-RPC request timed out: thread/resume
The daemon gave up at 30.0s while the construction finished at 31 to 34 seconds.
Deterministic A/B on a dev instance running the same code, pi provider, session transplanted from the failing thread (26.9 MB, rewritten cwd), with a delay injected into session construction to synthesize the loaded-host construction time, and temporary logging of the deadline each command is sent with:
Before, i.e. current upstream behaviour:
[bb-deadline] send thread/resume timeoutMs=undefined
[bb-deadline] FAIL thread/resume afterMs=30001: JSON-RPC request timed out: thread/resume
thread status error, exactly the production symptom.
After, i.e. with the deadline added:
[bb-deadline] send thread/resume timeoutMs=120000
[bb-deadline] ok thread/resume afterMs=35847
turn completed, thread idle. On the same instance thread/start reports timeoutMs=120000, ok afterMs=35454, which is the same work with the deadline already attached.
A cold resume of the same 26.9 MB session on an unloaded dev host takes about 15 seconds, on the loaded production host 31 to 34 seconds. The deadline has to cover that spread, and 30 seconds does not.
Root cause
packages/provider-bridge-protocol/src/bridge-kit/runtime-json-rpc.ts:
const timer = setTimeout(() => {
args.pending.delete(id);
reject(new Error(`JSON-RPC request timed out: ${message.method}`));
}, args.timeoutMs ?? 30_000);packages/agent-runtime/src/runtime.ts (2581 lines at upstream/main):
- line 234
const DEFAULT_THREAD_CREATION_REQUEST_TIMEOUT_MS = 2 * 60_000; - line 269
const threadCreationRequestTimeoutMs = options.threadCreation?.requestTimeoutMs ?? DEFAULT_THREAD_CREATION_REQUEST_TIMEOUT_MS; thread/startat line 1608 andthread/forkat line 1749 passtimeoutMs: threadCreationRequestTimeoutMsthread/resumebuilds its command at line 1912 and callssendCommandat line 1938 withrecoveryonly, notimeoutMs, so it falls through to the 30 second default
The provider side cannot answer earlier: for the pi provider, thread/resume reaches handleThreadConstruction → constructPiThreadSession → await session.start(), and the bridge replies with the provider thread id only after that resolves. Construction time therefore scales with the session, not with the request.
Proposed solution
Minimum, matching the existing convention at the other two construction sites:
let resolved: string;
try {
const result = await sendCommand({
proc,
message: plan,
resultSchema: threadIdentityResultSchema,
+ // A resume loads the thread's whole session, so it is construction
+ // work and needs the construction deadline, not the 30s transport
+ // default.
+ timeoutMs: threadCreationRequestTimeoutMs,
recovery: {A more structural option, if maintainers prefer it, is to decide the deadline from the command type inside sendCommand (a thread/start, thread/fork, thread/resume mapping) instead of an optional argument, so a future construction command cannot silently fall back to the transport default. That is what the fix on my fork does; it touches every sendCommand call site, so it is a judgement call which shape belongs here.
Testing
- Unit, small and deterministic: cover whichever shape lands. With a command-type mapping, assert
thread/start,thread/forkandthread/resumeall resolve to the construction deadline and that e.g.turn/startstays on the transport default. With the minimal diff, assert the resume command is sent withtimeoutMs(a recording adapter or a spy on the request args). Both fail before the change: the mapping returnsundefinedforthread/resume, and the minimal version sends notimeoutMs. - Behavioural, which is the one that actually pins the user-visible behaviour: the runtime option
threadCreation.requestTimeoutMsalready exists, so set it low (for example 2 seconds) and make the fake provider answerthread/resumelater than that. Before the change the resume succeeds with the low configured value, i.e. the option is ignored on the resume path; after the change the same call rejects withJSON-RPC request timed out: thread/resume. The fake provider script has no delay knob forthread/resumetoday, so this needs one small addition next to the existingdelay:Nsupport for turns. - If a heavier gate is wanted, run
packages/agent-runtimeintegration resume tests with a large synthetic session; that is slow, so I would keep it out of the default suite.
Residual risk
With the deadline attached, a provider that is genuinely stuck holds a turn for up to the construction deadline instead of 30 seconds before the turn fails. A progress heartbeat between the runtime and the provider bridge would separate a slow but healthy construction from a stalled one and would let the deadline be an idle timeout rather than a total one. That needs the provider bridge protocol, so it is a follow-up rather than part of this fix.
Environment
- bb-app 0.45.0, self-hosted, Linux, pi provider (
openai-codexmodel), full permission mode. - Producer of the failure: pi bridge worker idle-stopped after about 5 minutes (
host plugin worker became idle, uptime ≈300s), so the next message needs a cold resume of the whole session. - The same failure mode should affect any provider whose resume blocks on session construction, not only pi.
Activity
bb-slop-cop commentedon Oct 7, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotproviders,provider-pi.confirmed-repro.Diffuzmetall commentedon Oct 7, 2026
Follow-up after deploying the fix on the affected instance: the resume path is fixed, and the same class of failure showed up one command later.
Evidence from the thread that was failing (pi session of 31.6 MB), local time, after the daemon was restarted with the resume deadline raised:
08:22:38the pi session recordsstate/reconstructed, so the resume completed. Before the change the daemon had already given up at 30.0s and this line was reached only after the thread was killed.08:22:39state/input-pending, immediately followed bystate/session_before_compact: this session starts compacting as soon as it is loaded.08:23:08Command turn.submit failed / JSON-RPC request timed out: turn/start, the 30 second transport default again, now on prompt submission.Compaction on that session is not quick:
session_before_compactat08:01:46and the next session entry at08:06:23, about four and a half minutes.So the provider was busy doing legitimate, provider-side work and the daemon killed the prompt at 30 seconds. Two shapes for the fix, and I think the first is the right long term one:
The bridge should answer
turn/startimmediately with the compaction-in-progress outcome it already produces on other paths:Cannot submit a prompt while compaction is in progress. Wait for compaction to finish and retry.Then the runtime can retry or queue instead of holding a request open, and the user gets a fast, accurate answer rather than a timeout.
Give prompt submission the same provider-busy deadline as construction, which is what I applied as a local mitigation:
turn/startandturn/steernow share a ten minute provider-busy deadline withthread/start,thread/forkandthread/resume, in both the source fix and the deployed bundle.Shape 2 removes the immediate failure but keeps the failure mode where a genuinely stuck provider holds a turn for the full deadline, so shape 1 is still worth doing.
Diffuzmetall commentedon Oct 7, 2026
Confirmed on the affected instance, same heavy thread (
thr_pbsqhhv4c8, pi session grown to 32 MB):Zero
JSON-RPCtimeouts in the host daemon log since that daemon started. The same scenario on the previous, 30 second default build failed at 08:23:08 withJSON-RPC request timed out: turn/startand left the thread inerror.The margin is worth noting: that compaction took about seven minutes against the ten minute provider-busy deadline I gave
turn/startandturn/steer. So the timeout works but the outcome is still a race against how long compaction happens to take, which is the argument for the first shape above: the bridge should answer prompt submission with the compaction-in-progress outcome it already knows, and the runtime should retry, so no timeout value has to guess the maximum compaction time.Diffuzmetall commentedon Oct 7, 2026
One more guard shows up in the same window, worth recording here.
During the seven minute compaction of that session the thread logged:
The turn still completed at 09:48:01 and the thread went back to
idle, so this guard did not kill the run, but the thread carries an error event and the user sees it. It is a second, independent deadline: the runtime expectsturn/startedwithin 120 seconds of the provider accepting the prompt, and pi cannot start the turn until compaction finishes.So on a 32 MB session a prompt submitted at the wrong moment races two clocks, the 30 second transport default on
turn/startand this 120 second provider-turn-start guard, and compaction took about seven minutes. Raising either number only moves the race. The shape that removes it is still the one in my earlier comment: while the provider reportssession_before_compact/compaction_start, do not submit the prompt at all, or submit it and treat it as queued until the provider is ready, instead of timing the wait.Use construction deadline when restoring provider sessions (get-bb#5082)