Add create_thread and list_agents_and_models agent tools - #54213
Closed
eholk wants to merge 2 commits into
Closed
Conversation
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.
Contributor
Contributor
Author
|
Reopened as #57987 — GitHub wouldn't let me reopen this one after a force-push rewrote the branch. |
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 new built-in agent tools that let the agent spawn independent
sibling threads which appear in the agent sidebar and run in parallel with
the current conversation:
create_thread— creates a new thread with a user-supplied title andinitial prompt. The new thread runs on the user's behalf, persists like any
other thread, and does not report results back to the parent (use
spawn_agentfor that). The parent thread's active view is neverinterrupted.
list_agents_and_models— lets the agent enumerate configured agentsand, for the native agent, the models that are available. Useful for
choosing a cheaper model for bulk work (the motivating stress test:
"spawn 100 threads that each write a haiku, using Haiku rather than Opus").
Behavior
AgentPanel.retained_threadsjust like a user-createdthread, subject to the same
MaxIdleRetainedThreadseviction andThreadMetadataStorepersistence. Running threads are never evicted;finished threads are rehydrated from disk on click.
create_threadsupports optionalagentandmodeloverrides. An agentoverride does not mutate the panel's
selected_agentor thelast-used-agent preference — those are snapshotted and restored around the
call.
use_new_worktreefield is on the schema but currently returns an error;the flag is there so follow-up work can wire it through to the existing
handle_worktree_requestedflow without a schema change.Architecture
agent::ThreadEnvironmentgrows two new methods (create_sibling_thread,list_available_agents) with default impls that return an error, soexisting implementors are unaffected.
agent::SiblingThreadHosttrait bridges theagentcrate (whichcannot depend on UI) to
agent_ui.NativeAgentstores an optional host,NativeThreadEnvironmentforwards calls to it.AgentPanelimplements the host (AgentPanelSiblingHost) and installs iton the
NativeAgentwhenever a native-agent conversation view connects.AgentPanel::create_thread_with_optionsparameterizes the existingcreate_threadwith an initial content block, agent, and model override.The plain
create_threadbecomes a thin wrapper that passes defaults, sono existing call sites change.
The tool goes through the same
create_agent_thread→ConversationViewpath as the user-facing "new thread" action, so eviction, persistence, and
sidebar rendering are identical to user-created threads.
What's not in this PR
use_new_worktree: truecurrently returns an error. The existing worktreeflow (
handle_worktree_requested/open_worktree_workspace_and_start_thread)already creates a second
Workspaceinside the currentMultiWorkspacevia
find_or_create_workspace; a follow-up will thread a "background"placement parameter through that flow so it can skip
multi_workspace.activateand install the new thread without taking focus.initial success payload deliberately does not include a session ID because
the session is populated asynchronously and we have no downstream consumer
for it today.
Testing
cargo check --libandcargo clippy --no-depsare clean onagent,agent_ui, andsettings_ui.with a title and prompt, the user's active thread stays focused, the new
thread appears in the sidebar and begins generating.
list_agents_and_modelscorrectly enumerates the native agent with itsdefault model flagged, plus any configured external agents.
Suggested .rules additions
None required — a
.rulesfile for theagentcrate was added alongsidethis change documenting the non-obvious fact that a new built-in tool must
be listed in
assets/settings/default.json's built-in profiles and eitheradded to
TOOLSorEXCLUDED_TOOLSinsettings_ui/src/pages/tool_permissions_setup.rs. I hit both of those gatesduring this work.
Release Notes: