Skip to content

Stop bb cloud titles timing out on a hung model - #5024

Merged
ymichael merged 5 commits into
mainfrom
bb/fix-inconsistent-threat-titling-thr_dk9awzwfsd
Oct 6, 2026
Merged

ymichael merged 5 commits into
mainfrom
bb/fix-inconsistent-threat-titling-thr_dk9awzwfsd

Conversation

@ymichael

@ymichael ymichael commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

About 5% of prompts long enough to title never got a generated title. In the last 30 days on one server, 401 runs were titled, 13 failed and 5 timed out. Every failure was bb cloud's gateway timing out. The gateway sent AI_MODELS to OpenRouter as one request with a fallback list (model plus models). The primary, inception/mercury-2.5, returned 200 and then never finished the body on 14 of 50 direct calls. OpenRouter falls back only on errors, not slowness, so with the gateway's exact request it waited about 10.6s on a hung Mercury call before switching to Gemini. The gateway gives up at 4s, so 3 of 25 requests failed as "the model did not answer in time".

Latency probe (25 calls per configuration, gateway request shape, real title prompt; times in ms):

Request OK p50 p90 max
Gateway's old request 25/25 406 10,655 10,674
mercury-2.5 alone 36/50 ~370 ~1,000 hung (cut off at 15s)
gemini-2.5-flash-lite alone 50/50 ~510 ~690 1,229
nemotron-3.5-lightning alone 50/50 ~175 ~460 543

The privacy settings (zdr / data_collection: deny) and reasoning: none made no difference.

What changed

  • Completion requests try one model at a time, with a fresh 3-second timeout per model. The gateway shares transcription's retry loop and preserves accounting across attempts.
  • Production and staging use Gemini 2.5 Flash-Lite first, then Mercury 2.5. Nemotron is removed because probes found it invented titles for URL-only prompts.
  • The two model attempts have a combined timeout budget of approximately 6 seconds. The bb cloud plugin's completion HTTP timeout increases to 7 seconds, and the server's per-service timeout for titles and commit messages increases to 8 seconds, leaving room for request overhead.
  • Timeout logs record the attempted model instead of null.

The gateway changes require deployment; the outer timeout changes also require the updated bb server and bb cloud plugin. Slow requests can now wait longer during title generation and managed-worktree provisioning.

How you verified

  • pnpm exec turbo run test --filter=@bb/ai-gateway --filter=bb-plugin-bb-ai: 35 gateway tests and 24 plugin tests passed. Coverage includes a hanging primary model followed by a successful fallback with a fresh signal, billing, timeout logging, and the plugin's 7-second request timeout.
  • pnpm exec turbo run test --filter=@bb/server -- test/ai/ai-tasks.test.ts: 14 tests passed.
  • pnpm exec turbo run lint typecheck --filter=@bb/ai-gateway --filter=bb-plugin-bb-ai --filter=@bb/server: passed all available tasks.
  • Formatting and git diff --check passed.
  • Earlier live probe of the retry scheme, using the previous 2-second-per-model settings: 40/40 requests succeeded, p50 504ms, p90 686ms, max 2,411ms. One needed the fallback. The final 3-second settings have not been live-probed or deployed in this update.

AGENT GENERATED

ymichael and others added 4 commits October 6, 2026 09:31
About 5% of prompts long enough to title ended up untitled. Every
failure was latency: the bb cloud gateway gives up after 4s ("the
model did not answer in time"), or a service hits the 5s client
budget. There was one attempt, so a single slow answer left the
thread with its raw-prompt fallback for good.

When the first attempt times out or fails, make one more attempt in
the background with a 15s budget. Managed-worktree provisioning still
waits only for the first attempt. The retry skips threads that already
have a title, and a title set while the retry runs is kept. Both
provisioning paths now share one apply-and-rename step, so a late title
also reaches the provider session.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mercury 2.5 returned 200 and then never finished the body on 14 of 50
direct OpenRouter calls. With the gateway's exact request, OpenRouter
waited about 10.6s on those calls before falling back. The gateway
times out at 4s, so 3 of 25 requests failed as "the model did not
answer in time".

Gemini 2.5 Flash-Lite answered all 50 calls, with p90 690ms and max
1.2s. Mercury becomes the fallback because its titles are the best
when it answers. Nemotron is dropped because it made up titles for
URL-only prompts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gateway sent all models to OpenRouter as one request with a
fallback list. OpenRouter falls back only on errors, so when the
primary model hung, it waited about 10s, well past the gateway's 4s
limit. The title then failed even though the fallback answers in
under a second.

Completions now use the same per-model loop as transcription. Each
model is requested alone, with its own 2s limit. Two models take the
same 4s as the old single attempt, which stays within the 5s bb
waits. A timeout now logs the model that hung instead of null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title Fix missing auto-generated thread titles Stop bb cloud titles timing out on a hung model Oct 6, 2026
@ymichael
ymichael merged commit c41e0bb into main Oct 6, 2026
41 checks passed
@ymichael
ymichael deleted the bb/fix-inconsistent-threat-titling-thr_dk9awzwfsd branch October 6, 2026 17:48
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.

1 participant