pub struct SubagentTool<P, H = DefaultHooks, M = InMemoryStore, S = InMemoryStore>{ /* private fields */ }Expand description
Tool for spawning subagents.
This tool allows an agent to spawn a child agent that runs independently and returns only its final response.
§Example
ⓘ
use agent_sdk::subagent::{SubagentTool, SubagentConfig};
let config = SubagentConfig::new("analyzer")
.with_system_prompt("You analyze code...");
let tool = SubagentTool::new(config, provider.clone(), tools.clone());Implementations§
Source§impl<P> SubagentTool<P, DefaultHooks, InMemoryStore, InMemoryStore>where
P: LlmProvider + 'static,
impl<P> SubagentTool<P, DefaultHooks, InMemoryStore, InMemoryStore>where
P: LlmProvider + 'static,
Sourcepub fn new(
config: SubagentConfig,
provider: Arc<P>,
tools: Arc<ToolRegistry<()>>,
) -> Self
pub fn new( config: SubagentConfig, provider: Arc<P>, tools: Arc<ToolRegistry<()>>, ) -> Self
Create a new subagent tool with default hooks and in-memory stores.
Source§impl<P, H, M, S> SubagentTool<P, H, M, S>where
P: LlmProvider + Clone + 'static,
H: AgentHooks + Clone + 'static,
M: MessageStore + 'static,
S: StateStore + 'static,
impl<P, H, M, S> SubagentTool<P, H, M, S>where
P: LlmProvider + Clone + 'static,
H: AgentHooks + Clone + 'static,
M: MessageStore + 'static,
S: StateStore + 'static,
Sourcepub fn with_hooks<H2: AgentHooks + Clone + 'static>(
self,
hooks: Arc<H2>,
) -> SubagentTool<P, H2, M, S>
pub fn with_hooks<H2: AgentHooks + Clone + 'static>( self, hooks: Arc<H2>, ) -> SubagentTool<P, H2, M, S>
Create with custom hooks.
Sourcepub fn with_stores<M2, S2, MF, SF>(
self,
message_factory: MF,
state_factory: SF,
) -> SubagentTool<P, H, M2, S2>where
M2: MessageStore + 'static,
S2: StateStore + 'static,
MF: Fn() -> M2 + Send + Sync + 'static,
SF: Fn() -> S2 + Send + Sync + 'static,
pub fn with_stores<M2, S2, MF, SF>(
self,
message_factory: MF,
state_factory: SF,
) -> SubagentTool<P, H, M2, S2>where
M2: MessageStore + 'static,
S2: StateStore + 'static,
MF: Fn() -> M2 + Send + Sync + 'static,
SF: Fn() -> S2 + Send + Sync + 'static,
Create with custom store factories.
Sourcepub const fn config(&self) -> &SubagentConfig
pub const fn config(&self) -> &SubagentConfig
Get the subagent configuration.
Trait Implementations§
Source§impl<P, H, M, S> Tool<()> for SubagentTool<P, H, M, S>where
P: LlmProvider + Clone + 'static,
H: AgentHooks + Clone + 'static,
M: MessageStore + 'static,
S: StateStore + 'static,
impl<P, H, M, S> Tool<()> for SubagentTool<P, H, M, S>where
P: LlmProvider + Clone + 'static,
H: AgentHooks + Clone + 'static,
M: MessageStore + 'static,
S: StateStore + 'static,
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
Human-readable description of what the tool does
Source§fn input_schema(&self) -> Value
fn input_schema(&self) -> Value
JSON schema for the tool’s input parameters
Auto Trait Implementations§
impl<P, H, M, S> Freeze for SubagentTool<P, H, M, S>
impl<P, H = DefaultHooks, M = InMemoryStore, S = InMemoryStore> !RefUnwindSafe for SubagentTool<P, H, M, S>
impl<P, H, M, S> Send for SubagentTool<P, H, M, S>
impl<P, H, M, S> Sync for SubagentTool<P, H, M, S>
impl<P, H, M, S> Unpin for SubagentTool<P, H, M, S>
impl<P, H = DefaultHooks, M = InMemoryStore, S = InMemoryStore> !UnwindSafe for SubagentTool<P, H, M, S>
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