[Bug]: Worktree launch holds the agent ~6 s on an unbounded branch-name LLM call, with no visible stage #36889
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Keep the default worktree settings (
branchNamingMode: "static", no branch picked by hand). - Set the text generation model to a Codex model (here
gpt-6.1-sol, defaultreasoningEffortlow). - Start a new worktree thread with a short first message.
- Watch the time between "Workspace ready" and the agent's first output, and the server trace.
Expected behavior#
The agent starts right after the worktree exists (~1.5 s here). A friendlier branch name should not hold the agent back for long. If it does, the thread should say so.
Actual behavior#
The agent waited 6.3 s for an LLM to write a branch name. The thread showed no stage for that wait, so it looked hung.
Span tree of ThreadLaunchService.prepareInBackground (8.03 s total):
+0 ms fetchWorktreeBaseCommit 649 ms
+738 ms createWorktree (incl. refreshNewWorktreeIndex 495 ms) 832 ms
+1583 ms generateBranchNameFor → CodexTextGeneration.generateBranchName
→ runCodexJson.runCodexCommand 6295 ms
+7878 ms renameBranch 76 ms
+7982 ms prepared-run.release
From click to first agent output took 12.97 s. The branch name was 49% of that. The other three runCodexJson calls in the same trace took 5.95 s, 6.28 s and 5.98 s, including one with the server idle. This is a steady cost, not a startup spike.
Cause: apps/server/src/orchestration-v2/ThreadLaunchService.ts (main @ 4d47d0b76) forks the rename, then joins it before release:
// The agent must start on the branch name the thread will show.
if (branchRename !== null) yield* Fiber.join(branchRename);
The join has no time limit. The setup tracker has stages for fetch, checkout, submodules, setup-script and agent, but none for branch naming.
No current setting skips the LLM call. In all three branchNamingMode values (static, semantic, custom), a worktree thread with a temporary branch still calls generateBranchName. The only ways around it are to name the branch by hand or start the thread in local mode.
Most of the 6.3 s is the codex exec path, not the model. Spawning took 8 ms and MCP preflight 26 ms. Measured outside T3, a bare /chat/completions request to the same model took ~3 s, and a small model took 1.2–1.4 s. A codex exec with a small model still took ~5 s. Using an openaiCompatible text generator makes the call shorter but keeps the agent waiting.
Impact#
Major degradation or frequent failure
Version or commit#
0.1.10-nightly.20261114.4695 (code checked on main @ 4d47d0b76)
Environment#
Linux server, web client. Text generation through the Codex CLI with a GPT model behind an OpenAI-compatible proxy. Agent provider is Claude.
Logs or stack traces#
ThreadLaunchService.prepareInBackground 8031 ms
ThreadLaunchService.generateBranchNameFor 6295 ms
TextGeneration.generateBranchName 6295 ms
CodexTextGeneration.generateBranchName 6295 ms
runCodexJson.runCodexCommand 6285 ms
Possible fixes (any one helps)#
- Bound the wait. Join the rename with a timeout (1–2 s). If it runs over, release the agent on the temporary branch and let the rename finish in the background, or drop it. That relaxes the "agent starts on the shown name" rule only when the model is slow.
- Start naming earlier. The name only needs the first message, so generation could run alongside
fetchWorktreeBaseCommit/createWorktreeinstead of after them. That hides ~1.5 s of the wait. - Add a real off switch, for example
branchNamingMode: "off", which keeps the temporary or prefixed branch name and makes no LLM call. - Show the stage. Add a
branch-namesetup stage, such as "Naming branch…", so the wait isn't silent.
Workaround#
Name the branch by hand in the launch dialog, or use an openaiCompatible text generator with a small model to make the wait shorter.
tanstack-source added labelsbug
prakharsharma13(GitHub profile, opens in a new tab) linked this to #36943
Note
claude-opus-5-5 posting a comment on behalf of @kr4chinin.
Another data point from macOS,
0.1.11-nightly.20261118.4864. Here the wait is longer because of the text generation settings, and the serial order makes it worse.Setup: a monorepo with ~39k tracked files,
startFromOrigin: true. Text generation used a Codex model withreasoningEffort: highandserviceTier: priority.ThreadLaunchService.prepareInBackgroundfor one launch, 17.4 s total:+0 ms fetchWorktreeBaseCommit 3413 ms +3.4 s createWorktree (incl. refreshNewWorktreeIndex 887 ms) 3740 ms +7.2 s generateBranchNameFor → generateBranchName 10151 ms +17.4 s renameBranch 57 msTwo other launches in the same hour, in a smaller repo, waited 15.9 s and 17.6 s for the branch name. Those steps took 1.2–1.3 s in total. On a second Mac with the same settings and the same repo, the branch name took 4.9–5.5 s after a 3.2–3.3 s checkout. So the LLM call was the largest step in every launch I measured.
The concurrent start that the earlier comment suggests would hide most of this. Fetch and checkout already take 7 s here, and on a slow link the fetch alone varied from 2 s to 16 s while I measured
git ls-remoteon the same network. Started at launch, the name would usually be ready before the worktree exists. A time limit with a fallback to the temporary branch would cover the rest.One more detail from the same trace, in case it helps:
refreshNewWorktreeIndexranGitVcsDriver.createWorktree.refreshIndextwice in a row (328 ms and 356 ms). The launches in the smaller repo ran it once.Note
🤖 Claude Opus 5.5 responding on behalf of @aleksey852
Another data point, this time for Claude text generation (
0.1.12-nightly.20261121.5038, Linux). About half of eachClaudeTextGenerationcall is the Claude CLI sending telemetry on exit. The model accounts for the rest.One launch: ~9k tracked files, 840 MB worktree,
startFromOrigin: true, text generationclaude-haiku-5-5witheffort: low:fetchWorktreeBaseCommit 2639 ms createWorktree (refreshIndex 1154 ms) 1855 ms ClaudeTextGeneration.generateBranchName 5086 msOutside T3, with the flags T3 passes (
-p --model claude-haiku-5-5 --effort low --output-format json --tools "" --strict-mcp-config --disable-slash-commands), Claude Code 2.1.330, 2–3 runs each:env wall time default 3.24–3.44 s DISABLE_TELEMETRY=11.60–1.84 s DISABLE_AUTOUPDATER=1orDISABLE_ERROR_REPORTING=1no change With telemetry off,
duration_api_mswas 1367 ofduration_ms1394. Nearly all of the remaining time is the API call. As a workaround,"env": {"DISABLE_TELEMETRY": "1"}in~/.claude/settings.jsonworks, but it applies to every Claude Code session. On the T3 side, the variable could be set only for the one-shot text generation spawn.Even at ~1.7 s, the name still holds the agent. Starting it at launch (fix 2 above) would hide it behind fetch and checkout.
One more observation, from a single trace only:
fetchWorktreeBaseCommittook 2.6 s while afetchRemoteForStatusfor the same repo was still running (it had started 1.7 s earlier). A warmgit fetch originin that repo takes ~0.85 s. My guess is that the two fetches slowed each other down.juliusmarminge closed this
Sign in to join this conversation.
I investigated this issue and verified that
ThreadLaunchService.prepareInBackgroundinitiatesgenerateBranchNameForonly afterfetchWorktreeBaseCommitandcreateWorktreecomplete, blocking the agent release during the LLM call.The fix starts branch name generation immediately upon preparation so that the LLM call runs concurrently with fetch, checkout, and setup script execution, then joins the running fiber before renaming.