Add create_thread and list_agents_and_models agent tools - #57987
Merged
Conversation
eholk
force-pushed
the
create-thread-tool
branch
4 times, most recently
from
May 28, 2026 22:52
1f987de to
7e1a9a2
Compare
Introduces two new built-in agent tools that let an agent spawn independent sibling threads which appear in the agent sidebar and run in parallel with the current conversation.
Adds CreateThreadToolFeatureFlag (enabled for staff) and conditionally registers create_thread and list_agents_and_models in Thread::add_default_tools only when the flag is set.
When create_thread is called with use_new_worktree, open a new background workspace backed by linked git worktrees of the project's git repos (reusing the worktree picker's create flow) and spawn the thread there, rather than only sharing the parent's worktree. - Add git_ui::worktree_service::create_worktree_workspace, a Task- returning variant of handle_create_worktree that hands back the new workspace so the agent tool can create a thread in it. - Open the agent's worktree workspace in the background via a new MultiWorkspace::add_background_workspace, leaving the user where they are and giving the new workspace a clean checkout (no inherited open files or dock layout). This matches how non-worktree sibling threads are created in the background. - Dedup linked worktrees of the same underlying repo in start_worktree_creations so they don't collide on the same target path (previously a hard 'already exists' failure for both this flow and the manual Create worktree UI). - Report a non-fatal warning back to the calling agent when the project had multiple worktrees of the same repo and they were consolidated. - Add optional worktree_name to the create_thread tool input. Release Notes: - N/A
Anthony-Eid
approved these changes
Jun 1, 2026
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
Jun 2, 2026
…ies#57987) Adds two built-in agent tools, behind the staff-only `create-thread-tool` feature flag, that let the agent spawn independent sibling threads: - **`create_thread`** creates a new thread with a title and initial prompt. It runs on the user's behalf and shows up in the agent sidebar like a thread the user started themselves, but it runs in the background — the active thread is never interrupted — and it does **not** report results back to the caller. (Use `spawn_agent` when you want the results.) - **`list_agents_and_models`** enumerates the configured agents and, for the native agent, the available models, so the agent can pick a cheaper/faster model for bulk work. The motivating stress test was "spawn 100 threads that each write a haiku, using Haiku instead of Opus." By default the sibling shares the parent's project and worktree. If `use_new_worktree` is set, `create_thread` instead opens a new background workspace backed by fresh linked git worktrees of the project's repos — the same flow you get from the worktree picker's "Create worktree" — and starts the thread there. The new workspace opens as a background tab so it doesn't pull you away from what you're doing. A few notes on the design: - The `agent` crate can't depend on the UI, so there's a `SiblingThreadHost` trait that `agent_ui::AgentPanel` implements and installs on the `NativeAgent`. Tool calls in a native-agent thread route through it. - Sibling threads go through the same `create_agent_thread` → `ConversationView` path as the user-facing "new thread" action, so eviction, persistence, and sidebar rendering match user-created threads. - An explicit `agent`/`model` override doesn't clobber the panel's selected agent or the last-used-agent preference — those are snapshotted and restored around the call. - The worktree path reuses the existing "Create worktree" machinery rather than reimplementing it; the agent flow just opens the new workspace in the background instead of activating it. A couple of things I left out or want to call out: - There's no tool to operate on an already-created sibling by session id. The success payload deliberately omits it, since the session is populated asynchronously and nothing consumes it yet. - When a project has multiple worktrees that are linked worktrees of the *same* underlying repo, they collapse into a single new worktree (they resolve to the same target path). The tool returns a warning in that case rather than failing — and this also fixes a latent collision the manual "Create worktree" flow would hit in the same situation. Release Notes: - N/A
This was referenced Jun 10, 2026
This was referenced Jun 18, 2026
Closed
This was referenced Jul 1, 2026
This was referenced Jul 10, 2026
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
…ies#57987) Adds two built-in agent tools, behind the staff-only `create-thread-tool` feature flag, that let the agent spawn independent sibling threads: - **`create_thread`** creates a new thread with a title and initial prompt. It runs on the user's behalf and shows up in the agent sidebar like a thread the user started themselves, but it runs in the background — the active thread is never interrupted — and it does **not** report results back to the caller. (Use `spawn_agent` when you want the results.) - **`list_agents_and_models`** enumerates the configured agents and, for the native agent, the available models, so the agent can pick a cheaper/faster model for bulk work. The motivating stress test was "spawn 100 threads that each write a haiku, using Haiku instead of Opus." By default the sibling shares the parent's project and worktree. If `use_new_worktree` is set, `create_thread` instead opens a new background workspace backed by fresh linked git worktrees of the project's repos — the same flow you get from the worktree picker's "Create worktree" — and starts the thread there. The new workspace opens as a background tab so it doesn't pull you away from what you're doing. A few notes on the design: - The `agent` crate can't depend on the UI, so there's a `SiblingThreadHost` trait that `agent_ui::AgentPanel` implements and installs on the `NativeAgent`. Tool calls in a native-agent thread route through it. - Sibling threads go through the same `create_agent_thread` → `ConversationView` path as the user-facing "new thread" action, so eviction, persistence, and sidebar rendering match user-created threads. - An explicit `agent`/`model` override doesn't clobber the panel's selected agent or the last-used-agent preference — those are snapshotted and restored around the call. - The worktree path reuses the existing "Create worktree" machinery rather than reimplementing it; the agent flow just opens the new workspace in the background instead of activating it. A couple of things I left out or want to call out: - There's no tool to operate on an already-created sibling by session id. The success payload deliberately omits it, since the session is populated asynchronously and nothing consumes it yet. - When a project has multiple worktrees that are linked worktrees of the *same* underlying repo, they collapse into a single new worktree (they resolve to the same target path). The tool returns a warning in that case rather than failing — and this also fixes a latent collision the manual "Create worktree" flow would hit in the same situation. Release Notes: - N/A
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…ies#57987) Adds two built-in agent tools, behind the staff-only `create-thread-tool` feature flag, that let the agent spawn independent sibling threads: - **`create_thread`** creates a new thread with a title and initial prompt. It runs on the user's behalf and shows up in the agent sidebar like a thread the user started themselves, but it runs in the background — the active thread is never interrupted — and it does **not** report results back to the caller. (Use `spawn_agent` when you want the results.) - **`list_agents_and_models`** enumerates the configured agents and, for the native agent, the available models, so the agent can pick a cheaper/faster model for bulk work. The motivating stress test was "spawn 100 threads that each write a haiku, using Haiku instead of Opus." By default the sibling shares the parent's project and worktree. If `use_new_worktree` is set, `create_thread` instead opens a new background workspace backed by fresh linked git worktrees of the project's repos — the same flow you get from the worktree picker's "Create worktree" — and starts the thread there. The new workspace opens as a background tab so it doesn't pull you away from what you're doing. A few notes on the design: - The `agent` crate can't depend on the UI, so there's a `SiblingThreadHost` trait that `agent_ui::AgentPanel` implements and installs on the `NativeAgent`. Tool calls in a native-agent thread route through it. - Sibling threads go through the same `create_agent_thread` → `ConversationView` path as the user-facing "new thread" action, so eviction, persistence, and sidebar rendering match user-created threads. - An explicit `agent`/`model` override doesn't clobber the panel's selected agent or the last-used-agent preference — those are snapshotted and restored around the call. - The worktree path reuses the existing "Create worktree" machinery rather than reimplementing it; the agent flow just opens the new workspace in the background instead of activating it. A couple of things I left out or want to call out: - There's no tool to operate on an already-created sibling by session id. The success payload deliberately omits it, since the session is populated asynchronously and nothing consumes it yet. - When a project has multiple worktrees that are linked worktrees of the *same* underlying repo, they collapse into a single new worktree (they resolve to the same target path). The tool returns a warning in that case rather than failing — and this also fixes a latent collision the manual "Create worktree" flow would hit in the same situation. Release Notes: - N/A
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.
Adds two built-in agent tools, behind the staff-only
create-thread-toolfeature flag, that let the agent spawn independent sibling threads:create_threadcreates a new thread with a title and initial prompt. It runs on the user's behalf and shows up in the agent sidebar like a thread the user started themselves, but it runs in the background — the active thread is never interrupted — and it does not report results back to the caller. (Usespawn_agentwhen you want the results.)list_agents_and_modelsenumerates the configured agents and, for the native agent, the available models, so the agent can pick a cheaper/faster model for bulk work. The motivating stress test was "spawn 100 threads that each write a haiku, using Haiku instead of Opus."By default the sibling shares the parent's project and worktree. If
use_new_worktreeis set,create_threadinstead opens a new background workspace backed by fresh linked git worktrees of the project's repos — the same flow you get from the worktree picker's "Create worktree" — and starts the thread there. The new workspace opens as a background tab so it doesn't pull you away from what you're doing.A few notes on the design:
agentcrate can't depend on the UI, so there's aSiblingThreadHosttrait thatagent_ui::AgentPanelimplements and installs on theNativeAgent. Tool calls in a native-agent thread route through it.create_agent_thread→ConversationViewpath as the user-facing "new thread" action, so eviction, persistence, and sidebar rendering match user-created threads.agent/modeloverride doesn't clobber the panel's selected agent or the last-used-agent preference — those are snapshotted and restored around the call.A couple of things I left out or want to call out:
Release Notes: