Repository navigation
feat(mcp): launch a top-level thread with an explicit workspace choice - #2276
Merged
Merged
Conversation
Add the thread_launch tool. It starts an ordinary user-owned thread in the project root, a new worktree from a local or fetched origin branch, or an existing project worktree. Setup gates the first turn, and the launched thread cannot run with broader permission or interaction modes than its caller. Refs #2214
Delegation makes a supervised Coordinator wait for the user's approval before it creates a worktree. thread_launch has no approval flow yet, so it rejects that placement instead of bypassing the gate. Refs #2214
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Before this change, an agent had no way to start an ordinary top-level thread for the user. It could only delegate child work with
delegate_task, which makes a hidden Delegated thread in the caller's checkout or a new worktree at the caller's commit.The Mcode MCP server now has a
thread_launchtool. It starts a visible, user-owned thread in a workspace the agent names:Key choices:
createAndSendpath with no delegation lineage and no setup skip. Project setup therefore finishes before the first message runs.startFromOrigin, the service fetches the origin branch itself and passes the resolved commit. The coordinator's own origin path would block the tool call on a human fetch decision when the fetch fails.ExistingWorktreePlacementErrorwith the same messages, so the service can report them asinvalid_placement. The check runs before any thread row is written.delegate_taskwhen the result is needed back. An omitted workspace means the project root, not the caller's worktree.thread_launchrows in plain words, like fix(web): name Mcode thread tools and approvals in plain words #2274.Closes #2214. Part of #2205.
Why
Users ask agents to "start this in its own conversation" or "spin up a thread on a new worktree from main". Until now the agent could only fake that with a hidden delegated task.
thread_launchgives the user a real thread they own and can find in the sidebar, prepared before the agent starts. T3 Code'st3_thread_launchis the reference shape.UI Changes
A
thread_launchcall in the chat timeline.Review Notes
Verification, run locally:
apps/server: thread-launch-service, thread-control-toolkit, mcode-mcp-server, thread-creation-startup and agent-service-existing-worktree tests. 5 files, 124 tests pass.apps/web: tool-row-overflow and approval-receipts tests. 2 files, 116 tests pass.packages/contractsandpackages/thread-orchestrationtargeted tests pass.tsc --noEmitis clean for server and web.bun run lintshows only two existing warnings, inscripts/doctor.mjsandruntime-lifecycle.test.mjs.The launch tests use a real git fixture with a local branch and a differing origin branch. They cover these cases:
startFromOriginstarts at origin's commit.Known gaps:
thread_launchhas no approval flow yet, so it rejects that placement withforbiddeninstead of bypassing the gate. The root and existing-worktree placements still work. Supporting it later needs a launch approval kind in contracts and approval copy in the web app.thread_launch. Its wider scope is tracked in feat: offer Delegation without the wording gate, bounded by a runtime-mode ceiling #2218.No migrations, config changes, or docs changes.
Need help on this PR? Tag
@codesmith-botwith what you need.