Skip to content

fix(bots): a thread a bot starts answers with its job at once; a worktree that can't be set up ends that job once, with why - #2518

Merged
TheAnimatrix merged 4 commits into
masterfrom
bot-launch-prompt-ack
Dec 1, 2026
Merged

TheAnimatrix merged 4 commits into
masterfrom
bot-launch-prompt-ack

Conversation

@TheAnimatrix

@TheAnimatrix TheAnimatrix commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

When a personal bot starts a thread with thread_create, the call waits until the new thread's worktree is set up before it answers. On a Git-backed project that took about 1.6 s with no extra delay and about 3 s when setup was slow, even though the bot's job for the thread was already saved.

Change

  • When the bot's ledger keeps a job for the new thread, thread_create answers with that job right away. It no longer waits for the worktree.
  • Setup is still followed for that same run. If the worktree can't be set up, the job ends as failed, once, with why:
    • The job's saved line (bot_jobs.line) keeps Mousse's plain reason, held to the job line limit. Git's own output stays in the thread and the notice, not in the ledger.
    • A paused bot, or one that can't run now, gets the reason in its chat line with the link, instead of a notice turn.
  • The failure reaches the job whichever way the ledger hears of it first: thread_create's follow of the run, the run's end, the startup pass, or Retry. Retry clears the thread's record of the failure, so it now has the ledger read that record first (setup-retry). A restart that lost the earlier read still ends the job with why. The retried run's work then opens a follow-up job.
  • A job that already moved or ended is not changed again: one transition and one notice per failure.
  • A retried thread_create whose first reply was lost names the same job as the first call, for saved asks and plain launches alike.
  • Nothing changes for ordinary agents or for bots whose ledger can't take the job: those calls still wait for setup as before. Remote launches and startup prep are not touched.

Verification

Benchmark: the real thread_create tool on a Git-backed project copy with real local Git setup and a scripted provider. Six trials per build (three with no extra delay, three with 1,200 ms of added setup delay). Times are medians. The first-call path measured here did not change in the later review fixes.

Build Ack, no delay Ack, 1.2 s delay
Before (ccc3777) 1,596 ms 3,019 ms
Same base, without this change (control) 1,420 ms 2,544 ms
This branch 165 ms 190 ms

On this branch setup still finished on every trial and the run completed (setup finished a median 969 ms and 2,279 ms after the ack). The control on the same base shows the speed-up comes from this change, not from #2507.

node scripts/verify.mjs at be52f92:

  • PASS tests: 9 files, 217 tests: npx vitest run tests/run/botOwnerAsks.test.ts tests/run/botThreadsDaemon.test.ts tests/bots/botJobs.test.ts tests/run/botSupervision.test.ts tests/run/botThreadTools.test.ts tests/run/messageParent.test.ts tests/bots/botNoticeQueue.test.ts tests/bots/botDeviceHeld.test.ts tests/run/setupFailureRetry.test.ts
  • PASS typecheck:node: tsc --noEmit -p tsconfig.node.json
  • PASS typecheck:web: tsc --noEmit -p tsconfig.web.json

Tests cover:

  • The prompt answer with the job before setup, against a real Git worktree that can't be made.
  • The job's saved line and its one notice, whether thread_create's follow or the run's end tells it first.
  • A paused bot's chat line with the reason, for both paths, once.
  • Retry after the follow was lost: the ledger still reads the first run's failure as Retry starts.
  • A retried call naming the first job, for a plain launch and for a saved ask whose first reply was lost.
  • Another bot's job left alone, and a bot whose ledger can't take the failure still waiting for setup.

Not covered by a test: the one-line wiring in MmsProfileServices from setup-retry to checkJobs (typechecked only).

Notes

No issue

…tree that can't be set up ends that job once, with why

thread_create no longer waits for a new worktree when the bot's ledger keeps a job for the thread. The job's notice says why setup failed, whether thread_create's follow sees it or the ledger reads it when the run ends, and a Retry that already started a newer run does not hide it.
…ads it first, and a retried thread_create names the same job
@TheAnimatrix
TheAnimatrix merged commit 6f0d244 into master Dec 1, 2026
11 checks passed
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