pub struct SubagentTool<LLM> { /* private fields */ }Expand description
A tool that spawns specialized subagents to handle complex tasks.
Allows the main agent to delegate work to specialized subagents that have different capabilities and run in isolated context windows.
§Example
use aither_agent::specialized::task::{SubagentTool, SubagentType};
// Create subagent tool
let mut subagent_tool = SubagentTool::new(llm.clone());
// Register an "explore" subagent type
subagent_tool.register("explore", SubagentType::new(
"Codebase explorer for finding files and searching code",
|llm| Agent::builder(llm)
.system_prompt("You are a codebase explorer...")
.tool(FsTool::new())
.max_iterations(15)
.build()
));
let agent = Agent::builder(llm)
.tool(subagent_tool)
.build();Implementations§
Source§impl<LLM: Clone + Sync> SubagentTool<LLM>
impl<LLM: Clone + Sync> SubagentTool<LLM>
Sourcepub fn with_base_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_base_dir(self, dir: impl Into<PathBuf>) -> Self
Sets the base directory for resolving relative paths.
Paths like subagents/... and skills/... will be resolved
relative to this directory.
Sourcepub fn with_file_mounts<I>(self, mounts: I) -> Selfwhere
I: IntoIterator<Item = SubagentFileMount>,
pub fn with_file_mounts<I>(self, mounts: I) -> Selfwhere
I: IntoIterator<Item = SubagentFileMount>,
Sets explicit mount mappings for resolving subagent file paths.
Mappings are checked in order and matched by virtual path prefix.
Sourcepub fn with_terminal_tool_factory(self, factory: TerminalToolFactory) -> Self
pub fn with_terminal_tool_factory(self, factory: TerminalToolFactory) -> Self
Sets the terminal tool factory used for subagents.
Sourcepub fn register(&mut self, name: impl Into<String>, subagent: SubagentType<LLM>)
pub fn register(&mut self, name: impl Into<String>, subagent: SubagentType<LLM>)
Register a subagent type.
Sourcepub fn with_type(
self,
name: impl Into<String>,
subagent: SubagentType<LLM>,
) -> Self
pub fn with_type( self, name: impl Into<String>, subagent: SubagentType<LLM>, ) -> Self
Register a subagent type (builder pattern).
Sourcepub fn type_descriptions(&self) -> Vec<(&str, &str)>
pub fn type_descriptions(&self) -> Vec<(&str, &str)>
Returns a list of registered subagent types with their descriptions.
Useful for injecting into system prompts so the main agent knows what subagents are available.
Source§impl<LLM: LanguageModel + Clone + Sync> SubagentTool<LLM>
impl<LLM: LanguageModel + Clone + Sync> SubagentTool<LLM>
Sourcepub fn with_definition(self, def: SubagentDefinition) -> Self
pub fn with_definition(self, def: SubagentDefinition) -> Self
Register a subagent from a definition (builder pattern).
Creates a subagent type from a SubagentDefinition loaded from a file.
The subagent will use the definition’s system prompt and max iterations.
Sourcepub fn with_builtins(self) -> Self
pub fn with_builtins(self) -> Self
Register all builtin subagents.
Loads subagents from embedded definition files (explore, plan, etc.).
Trait Implementations§
Source§impl<LLM> Debug for SubagentTool<LLM>
impl<LLM> Debug for SubagentTool<LLM>
Source§impl<LLM> Tool for SubagentTool<LLM>
impl<LLM> Tool for SubagentTool<LLM>
Source§type Arguments = SubagentArgs
type Arguments = SubagentArgs
schemars::JsonSchema and serde::de::DeserializeOwned.
Its rustdoc becomes the default tool description.Source§type Res = ToolResult
type Res = ToolResult
Auto Trait Implementations§
impl<LLM> !RefUnwindSafe for SubagentTool<LLM>
impl<LLM> !UnwindSafe for SubagentTool<LLM>
impl<LLM> Freeze for SubagentTool<LLM>
impl<LLM> Send for SubagentTool<LLM>
impl<LLM> Sync for SubagentTool<LLM>
impl<LLM> Unpin for SubagentTool<LLM>
impl<LLM> UnsafeUnpin for SubagentTool<LLM>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more