pub struct AgentTool { /* private fields */ }Expand description
AgentTool wraps an Agent to make it callable as a Tool.
When the parent LLM generates a function call targeting this tool, the framework executes the wrapped agent, captures its final response, and returns it as the tool’s result.
Implementations§
Source§impl AgentTool
impl AgentTool
Sourcepub fn with_config(agent: Arc<dyn Agent>, config: AgentToolConfig) -> Self
pub fn with_config(agent: Arc<dyn Agent>, config: AgentToolConfig) -> Self
Create a new AgentTool with custom configuration.
Sourcepub fn skip_summarization(self, skip: bool) -> Self
pub fn skip_summarization(self, skip: bool) -> Self
Set whether to skip summarization.
Sourcepub fn forward_artifacts(self, forward: bool) -> Self
pub fn forward_artifacts(self, forward: bool) -> Self
Set whether to forward artifacts.
Sourcepub fn input_schema(self, schema: Value) -> Self
pub fn input_schema(self, schema: Value) -> Self
Set custom input schema.
Sourcepub fn output_schema(self, schema: Value) -> Self
pub fn output_schema(self, schema: Value) -> Self
Set custom output schema.
Sourcepub fn session_snapshot(self, snapshot: AgentToolSessionSnapshot) -> Self
pub fn session_snapshot(self, snapshot: AgentToolSessionSnapshot) -> Self
Choose which parent session data is snapshotted into the isolated child session.
Sourcepub fn forward_memory(self, forward: bool) -> Self
pub fn forward_memory(self, forward: bool) -> Self
Set whether the wrapped agent can access the parent’s memory service.
Set whether the wrapped agent can access the parent’s parallel shared state.
This defaults to true to preserve the historical AgentTool behavior.
Sourcepub fn forward_events(self, forward: bool) -> Self
pub fn forward_events(self, forward: bool) -> Self
Set whether child events are emitted through the parent tool context.
The default is false for backward compatibility. State and artifact
deltas are merged regardless of this setting.
Sourcepub fn failure_mode(self, mode: AgentToolFailureMode) -> Self
pub fn failure_mode(self, mode: AgentToolFailureMode) -> Self
Choose whether delegated failures are returned as JSON or propagated.
Sourcepub fn propagate_failures(self, propagate: bool) -> Self
pub fn propagate_failures(self, propagate: bool) -> Self
Set whether delegated failures should be propagated as tool errors.
Sourcepub fn max_delegation_depth(self, max_depth: u32) -> Self
pub fn max_delegation_depth(self, max_depth: u32) -> Self
Bound the number of nested agent-as-tool delegations.
Sourcepub fn reject_child_handoffs(self, reject: bool) -> Self
pub fn reject_child_handoffs(self, reject: bool) -> Self
Reject child handoff events that cannot be executed by AgentTool itself.
Sourcepub fn execute_child_handoffs(
self,
agents: impl IntoIterator<Item = Arc<dyn Agent>>,
) -> Self
pub fn execute_child_handoffs( self, agents: impl IntoIterator<Item = Arc<dyn Agent>>, ) -> Self
Executes child handoffs using the supplied exact target registry.
Disabled by default for backward compatibility. When enabled, a child transfer remains inside the nested invocation until the terminal member returns, after which its result is returned to the original caller.
Sourcepub fn history_max_events(self, max_events: usize) -> Self
pub fn history_max_events(self, max_events: usize) -> Self
Limits the parent history copied into a delegated session.
A value of zero copies no history while still allowing a filtered state snapshot when parent-session forwarding is enabled.
Sourcepub fn state_keys(
self,
keys: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn state_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Copies only these exact state keys into a delegated session.
Sourcepub fn output_state_keys(
self,
keys: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn output_state_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Allows delegated state writes only to these exact keys.
Sourcepub fn state_merge_policy(self, policy: AgentToolStateMergePolicy) -> Self
pub fn state_merge_policy(self, policy: AgentToolStateMergePolicy) -> Self
Selects how child state writes merge with concurrent parent updates.
Sourcepub fn state_merge_exempt_keys(
self,
keys: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn state_merge_exempt_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Exempts trusted framework-owned keys from concurrent merge checks.
Output allowlists still apply. This is intended for runtime bookkeeping that is deliberately updated by both the parent and delegated context.
Sourcepub fn artifact_prefixes(
self,
prefixes: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn artifact_prefixes( self, prefixes: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Allows artifact writes only when their names start with one of these prefixes.
Trait Implementations§
Source§impl Tool for AgentTool
impl Tool for AgentTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn parameters_schema(&self) -> Option<Value>
fn parameters_schema(&self) -> Option<Value>
Source§fn response_schema(&self) -> Option<Value>
fn response_schema(&self) -> Option<Value>
Source§fn is_long_running(&self) -> bool
fn is_long_running(&self) -> bool
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<dyn ToolContext>,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<dyn ToolContext>,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn declaration(&self) -> Value
fn declaration(&self) -> Value
Source§fn enhanced_description(&self) -> String
fn enhanced_description(&self) -> String
Source§fn is_builtin(&self) -> bool
fn is_builtin(&self) -> bool
google_search, url_context). Read more