pub struct SubAgent { /* private fields */ }Expand description
A tool that wraps an agent, enabling multi-agent composition.
When executed, constructs a fresh Agent via the options_factory,
sends the prompt extracted from tool call params, and maps the
AgentResult into an AgentToolResult.
Implementations§
Source§impl SubAgent
impl SubAgent
Sourcepub fn new(
name: impl Into<String>,
label: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, label: impl Into<String>, description: impl Into<String>, ) -> Self
Start building a sub-agent tool with the given identity.
Defaults to a schema that accepts a prompt string parameter.
Use with_options to configure the inner agent.
Sourcepub fn simple(
name: impl Into<String>,
label: impl Into<String>,
description: impl Into<String>,
system_prompt: impl Into<String>,
model: ModelSpec,
stream_fn: Arc<dyn StreamFn>,
) -> Self
pub fn simple( name: impl Into<String>, label: impl Into<String>, description: impl Into<String>, system_prompt: impl Into<String>, model: ModelSpec, stream_fn: Arc<dyn StreamFn>, ) -> Self
Convenience constructor that builds a fully configured sub-agent.
Creates an AgentOptions::new_simple() internally with the provided
system prompt, model, and stream function.
Sourcepub fn with_schema(self, schema: Value) -> Self
pub fn with_schema(self, schema: Value) -> Self
Set a custom JSON Schema for the tool parameters.
Sourcepub const fn with_requires_approval(self, requires: bool) -> Self
pub const fn with_requires_approval(self, requires: bool) -> Self
Set whether this tool requires approval before execution.
Sourcepub fn with_options(
self,
f: impl Fn() -> AgentOptions + Send + Sync + 'static,
) -> Self
pub fn with_options( self, f: impl Fn() -> AgentOptions + Send + Sync + 'static, ) -> Self
Set the factory closure that creates agent options for each execution.
Sourcepub fn with_map_result(
self,
f: impl Fn(AgentResult) -> AgentToolResult + Send + Sync + 'static,
) -> Self
pub fn with_map_result( self, f: impl Fn(AgentResult) -> AgentToolResult + Send + Sync + 'static, ) -> Self
Set a custom result mapper from AgentResult to AgentToolResult.
Trait Implementations§
Source§impl AgentTool for SubAgent
impl AgentTool for SubAgent
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn parameters_schema(&self) -> &Value
fn parameters_schema(&self) -> &Value
Source§fn requires_approval(&self) -> bool
fn requires_approval(&self) -> bool
false — tools execute immediately.