pub struct AsToolOptions {
pub name: Option<String>,
pub description: Option<String>,
pub arg_name: Option<String>,
pub arg_description: Option<String>,
pub approval_mode: ApprovalMode,
pub stream_callback: Option<AgentToolStreamCallback>,
pub propagate_session: bool,
}Expand description
Options for Agent::as_tool.
Fields§
§name: Option<String>The tool name. Defaults to the agent’s name (else its id).
description: Option<String>The tool description. Defaults to the agent’s description (else empty).
arg_name: Option<String>The single string argument’s name. Defaults to "task".
arg_description: Option<String>The argument’s description. Defaults to "Task for {tool_name}".
approval_mode: ApprovalModeWhether calls to this delegated tool require human approval before
executing (default: no). Mirrors upstream as_tool(approval_mode=…).
stream_callback: Option<AgentToolStreamCallback>Observe the sub-agent’s streamed updates as they arrive. When set,
the wrapper runs the sub-agent via run_stream and invokes the
callback on every update before aggregating the final response.
Mirrors upstream as_tool(stream_callback=…).
propagate_session: boolForward the parent agent’s session to the sub-agent, so both share the same session identity and state bag.
The sub-agent receives a AgentSession::child of the parent’s
session: same session_id, shared state, but an isolated
service_session_id — the parent’s server-side conversation pointer
(whose tool call is still pending mid-run) must not leak into the
sub-agent’s own service calls. Mirrors upstream
as_tool(propagate_session=True) with the child-session isolation
fix (microsoft/agent-framework#5875). Defaults to false (a fresh
session per call).
Implementations§
Source§impl AsToolOptions
impl AsToolOptions
pub fn new() -> Self
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the tool description.
Sourcepub fn arg_name(self, arg_name: impl Into<String>) -> Self
pub fn arg_name(self, arg_name: impl Into<String>) -> Self
Set the argument name (default "task").
Sourcepub fn arg_description(self, arg_description: impl Into<String>) -> Self
pub fn arg_description(self, arg_description: impl Into<String>) -> Self
Set the argument description.
Sourcepub fn approval_mode(self, mode: ApprovalMode) -> Self
pub fn approval_mode(self, mode: ApprovalMode) -> Self
Require human approval before every call to the delegated tool.
Sourcepub fn stream_callback(self, callback: AgentToolStreamCallback) -> Self
pub fn stream_callback(self, callback: AgentToolStreamCallback) -> Self
Observe the sub-agent’s streamed updates (see
AsToolOptions::stream_callback).
Sourcepub fn propagate_session(self, propagate: bool) -> Self
pub fn propagate_session(self, propagate: bool) -> Self
Forward the parent agent’s session to the sub-agent (see
AsToolOptions::propagate_session).
Trait Implementations§
Source§impl Clone for AsToolOptions
impl Clone for AsToolOptions
Source§fn clone(&self) -> AsToolOptions
fn clone(&self) -> AsToolOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more