pub struct SubAgentTool<LLM> { /* private fields */ }Expand description
A sub-agent tool that spawns a fresh agent for each call.
This allows building hierarchies of agents, where a main agent can delegate specific tasks to specialized sub-agents.
The subagent uses a single model for all tiers (advanced/balanced/fast).
§Example
ⓘ
let reviewer_tool = SubAgentTool::new(claude.clone())
.name("code-reviewer")
.description("Reviews code for security and quality issues")
.system_prompt("You are a code reviewer...");
let main_agent = Agent::builder(claude)
.tool(reviewer_tool)
.build();
// Main agent can now delegate review tasks
main_agent.query("Write and review a new function").await?;Implementations§
Source§impl<LLM: Clone> SubAgentTool<LLM>
impl<LLM: Clone> SubAgentTool<LLM>
Trait Implementations§
Source§impl<LLM> Debug for SubAgentTool<LLM>
impl<LLM> Debug for SubAgentTool<LLM>
Source§impl<LLM> Tool for SubAgentTool<LLM>where
LLM: LanguageModel + Clone + 'static,
impl<LLM> Tool for SubAgentTool<LLM>where
LLM: LanguageModel + Clone + 'static,
Source§type Arguments = SubAgentQuery
type Arguments = SubAgentQuery
Tool arguments type. Must implement
schemars::JsonSchema and serde::de::DeserializeOwned.
Its rustdoc becomes the default tool description.Source§type Res = ToolResult
type Res = ToolResult
Raw return type from the tool implementation.
Auto Trait Implementations§
impl<LLM> Freeze for SubAgentTool<LLM>where
LLM: Freeze,
impl<LLM> RefUnwindSafe for SubAgentTool<LLM>where
LLM: RefUnwindSafe,
impl<LLM> Send for SubAgentTool<LLM>where
LLM: Send,
impl<LLM> Sync for SubAgentTool<LLM>where
LLM: Sync,
impl<LLM> Unpin for SubAgentTool<LLM>where
LLM: Unpin,
impl<LLM> UnsafeUnpin for SubAgentTool<LLM>where
LLM: UnsafeUnpin,
impl<LLM> UnwindSafe for SubAgentTool<LLM>where
LLM: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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