Skip to main content

SubagentTool

Struct SubagentTool 

Source
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(), || {
    std::sync::Arc::new(agent_sdk::InMemoryEventStore::new())
});

Implementations§

Source§

impl<P> SubagentTool<P, DefaultHooks, InMemoryStore, InMemoryStore>
where P: LlmProvider + 'static,

Source

pub fn new<EF>( config: SubagentConfig, provider: Arc<P>, tools: Arc<ToolRegistry<()>>, event_store_factory: EF, ) -> Self
where EF: Fn() -> Arc<dyn EventStore> + Send + Sync + 'static,

Create a new subagent tool with default hooks and in-memory message/state 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,

Source

pub fn with_hooks<H2: AgentHooks + Clone + 'static>( self, hooks: Arc<H2>, ) -> SubagentTool<P, H2, M, S>

Create with custom hooks.

Source

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.

Source

pub const fn config(&self) -> &SubagentConfig

Get the subagent configuration.

Trait Implementations§

Source§

impl<P, H, M, S, Ctx> Tool<Ctx> for SubagentTool<P, H, M, S>
where P: LlmProvider + Clone + 'static, H: AgentHooks + Clone + 'static, M: MessageStore + 'static, S: StateStore + 'static, Ctx: Send + Sync + 'static,

Source§

type Name = DynamicToolName

The type of name for this tool.
Source§

fn name(&self) -> DynamicToolName

Returns the tool’s strongly-typed name.
Source§

fn display_name(&self) -> &'static str

Human-readable display name for UI (e.g., “Read File” vs “read”). Read more
Source§

fn description(&self) -> &'static str

Human-readable description of what the tool does.
Source§

fn input_schema(&self) -> Value

JSON schema for the tool’s input parameters.
Source§

fn tier(&self) -> ToolTier

Permission tier for this tool.
Source§

async fn execute( &self, ctx: &ToolContext<Ctx>, input: Value, ) -> Result<ToolResult>

Execute the tool with the given input. Read more

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, M, S> UnsafeUnpin 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,