Skip to content

[Bug]: Antigravity branch names can time out because runtime startup and session-file cleanup run inside the 20 s BRANCH_NAME_TIMEOUT #41381

Open

Description

@Sawtaytoes

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

  1. Set the Text Generation Model to Antigravity (gemini-4-neon here) and leave the Source Control Writer Model unset (or set the Source Control Writer Model to Antigravity).
  2. Start a new worktree thread with an initial message, and let T3 Code pick the temporary branch so ThreadLaunchService asks for a branch name.

Expected behavior

The branch gets renamed. Or, if a provider can't name a branch in time, the 20 s budget at least goes to the model and not to setup and cleanup.

Actual behavior

Sometimes, it fails with:

Could not rename the worktree branch, so it stays t3/<id>. Text generation failed in generateBranchName: Timed out after 20 seconds.

generateBranchNameFor wraps generateBranchName in Effect.timeoutOrElse with BRANCH_NAME_TIMEOUT = "20 seconds" (ThreadLaunchService.ts:72, :622-632). On the Antigravity path, AntigravityTextGeneration.runJson cold-starts a fresh ACP runtime, runs the prompt, and then runs the removeAntigravitySessionFiles finalizer, all inside that window (AntigravityTextGeneration.ts:158-173, :335-337). Antigravity's own limit is ANTIGRAVITY_TIMEOUT_MS = 180_000, so the 20 s outer limit is what fails.

The overhead can use most of the 20 s. Here is one runJson from server.trace.ndjson (a title generation, which uses the same path) that took 22.64 s total:

span time
isAntigravityTextGenerationAvailable 0.23 s
AntigravityDriver.makeRuntime 6.75 s
AntigravityDriver.startCompatible 1.81 s
session/prompt 9.16 s
AntigravityTextGeneration.hasOnlyRuntimeDirectories 0.13 s
removeAntigravitySessionFiles 3.44 s

That's about 12 s of runtime startup plus cleanup, which leaves ~8 s for the model. Other runJson calls in the same hour took 16.6 s, 21.1 s, and 38.2 s. The branch-name call that failed ran 21.4 s in the outer generateBranchNameFor span before the timeout interrupted its runJson.

What I can't prove: the per-span breakdown is from a title call, not from the branch-name call that timed out, so I'm calling startup and cleanup a likely contributor, not the proven cause. The host was under heavy load at the time, which probably made startup and cleanup slower than usual. I saw two branch-name timeouts in one evening; I don't have a failure rate. Related: #23877 (cleanup counts against the 180 s Antigravity timeout) and the closed #36889 (branch naming holding the agent).

Impact

Minor bug or occasional failure

Version or commit

0.1.11. On main @ f9f34aa, branch naming now starts while the worktree is created (#36904), and Antigravity applies the saved thinking level (#39720). The parts this report is about haven't changed: the 20 s BRANCH_NAME_TIMEOUT still wraps generateBranchName, and Antigravity runtime startup and session-file cleanup still run inside it.

Environment

Linux x64, headless t3 serve in Docker, Antigravity gemini-4-neon as the text generation model

Workaround

Switch branch naming to a model that doesn't cold-start a runtime per call. Branch naming initially selects the Source Control Writer Model when it is set, enabled for the project, and usable for text generation, and the Text Generation Model otherwise, so change whichever one it selects. Codex worked for me.

What I think the fix is

Run removeAntigravitySessionFiles (and the runtime teardown) after the result is returned, outside the caller's timeout, so cleanup never costs the caller. For the cold start, either reuse a warm runtime for text generation or give providers with a known startup cost a longer branch-name budget.

Activity

  1. changed the title [-][Bug]: Antigravity branch names time out because runtime startup and session-file cleanup use ~12 s of the 20 s BRANCH_NAME_TIMEOUT[/-] [+][Bug]: Antigravity branch names can time out because runtime startup and session-file cleanup run inside the 20 s BRANCH_NAME_TIMEOUT[/+] on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions