pub struct DelegateTool { /* private fields */ }Expand description
Tool that delegates a subtask to a named agent with a different model_provider/model configuration. Enables multi-agent workflows where a primary agent can hand off specialized work (research, coding, summarization) to purpose-built sub-agents.
Supports three execution modes:
- Synchronous (default): blocks until the sub-agent completes.
- Background (
background: true): spawns the sub-agent in a tokio task and returns atask_idimmediately. - Parallel (
parallel: [...]): runs multiple agents concurrently and returns all results.
Background results are persisted to workspace/delegate_results/{task_id}.json
and can be retrieved via action: "check_result".
Implementations§
Source§impl DelegateTool
impl DelegateTool
pub fn new( agents: HashMap<String, AliasedAgentConfig>, global_credential: Option<String>, security: Arc<SecurityPolicy>, ) -> DelegateTool
pub fn new_with_options( agents: HashMap<String, AliasedAgentConfig>, global_credential: Option<String>, security: Arc<SecurityPolicy>, provider_runtime_options: ModelProviderRuntimeOptions, ) -> DelegateTool
Sourcepub fn with_depth(
agents: HashMap<String, AliasedAgentConfig>,
global_credential: Option<String>,
security: Arc<SecurityPolicy>,
depth: u32,
) -> DelegateTool
pub fn with_depth( agents: HashMap<String, AliasedAgentConfig>, global_credential: Option<String>, security: Arc<SecurityPolicy>, depth: u32, ) -> DelegateTool
Create a DelegateTool for a sub-agent (with incremented depth).
When sub-agents eventually get their own tool registry, construct
their DelegateTool via this method with depth: parent.depth + 1.
pub fn with_depth_and_options( agents: HashMap<String, AliasedAgentConfig>, global_credential: Option<String>, security: Arc<SecurityPolicy>, depth: u32, provider_runtime_options: ModelProviderRuntimeOptions, ) -> DelegateTool
Sourcepub fn with_parent_tools(
self,
parent_tools: Arc<RwLock<RawRwLock, Vec<Arc<dyn Tool>>>>,
) -> DelegateTool
pub fn with_parent_tools( self, parent_tools: Arc<RwLock<RawRwLock, Vec<Arc<dyn Tool>>>>, ) -> DelegateTool
Attach parent tools used to build sub-agent allowlist registries.
Sourcepub fn with_multimodal_config(self, config: MultimodalConfig) -> DelegateTool
pub fn with_multimodal_config(self, config: MultimodalConfig) -> DelegateTool
Attach multimodal configuration for sub-agent tool loops.
Sourcepub fn with_delegate_config(self, config: DelegateToolConfig) -> DelegateTool
pub fn with_delegate_config(self, config: DelegateToolConfig) -> DelegateTool
Attach global delegate tool configuration for default timeout values.
Sourcepub fn parent_tools_handle(&self) -> Arc<RwLock<RawRwLock, Vec<Arc<dyn Tool>>>>
pub fn parent_tools_handle(&self) -> Arc<RwLock<RawRwLock, Vec<Arc<dyn Tool>>>>
Return a shared handle to the parent tools list. Callers can push additional tools (e.g. MCP wrappers) after construction.
Sourcepub fn with_workspace_dir(self, workspace_dir: PathBuf) -> DelegateTool
pub fn with_workspace_dir(self, workspace_dir: PathBuf) -> DelegateTool
Attach the workspace directory for system prompt enrichment.
Sourcepub fn with_cancellation_token(self, token: CancellationToken) -> DelegateTool
pub fn with_cancellation_token(self, token: CancellationToken) -> DelegateTool
Attach a cancellation token for cascade control of background tasks. When the token is cancelled, all background sub-agents are aborted.
Sourcepub fn cancellation_token(&self) -> &CancellationToken
pub fn cancellation_token(&self) -> &CancellationToken
Return the cancellation token for external cascade control.
Sourcepub fn with_memory(self, memory: Arc<dyn Memory>) -> DelegateTool
pub fn with_memory(self, memory: Arc<dyn Memory>) -> DelegateTool
Attach memory for namespace isolation on delegate agents.
Sourcepub fn with_providers_models(
self,
m: HashMap<String, HashMap<String, ModelProviderConfig>>,
) -> DelegateTool
pub fn with_providers_models( self, m: HashMap<String, HashMap<String, ModelProviderConfig>>, ) -> DelegateTool
Attach nested model provider map for brain resolution.
Sourcepub fn with_risk_profiles(
self,
m: HashMap<String, RiskProfileConfig>,
) -> DelegateTool
pub fn with_risk_profiles( self, m: HashMap<String, RiskProfileConfig>, ) -> DelegateTool
Attach risk profiles for depth/timeout resolution.
Sourcepub fn with_runtime_profiles(
self,
m: HashMap<String, RuntimeProfileConfig>,
) -> DelegateTool
pub fn with_runtime_profiles( self, m: HashMap<String, RuntimeProfileConfig>, ) -> DelegateTool
Attach runtime profiles for agentic/tools/iteration resolution.
Sourcepub fn with_skill_bundles(
self,
m: HashMap<String, SkillBundleConfig>,
) -> DelegateTool
pub fn with_skill_bundles( self, m: HashMap<String, SkillBundleConfig>, ) -> DelegateTool
Attach skill bundles for skills-directory resolution.
Sourcepub fn with_root_config(self, config: Arc<Config>) -> DelegateTool
pub fn with_root_config(self, config: Arc<Config>) -> DelegateTool
Attach the loaded root config so DelegateTool can resolve a
per-target SecurityPolicy at delegate time, validate it as a
subset of the caller’s policy, and share the caller’s
PerSenderTracker with the delegated run.
Source§impl DelegateTool
impl DelegateTool
Sourcepub fn cancel_all_background_tasks(&self)
pub fn cancel_all_background_tasks(&self)
Cancel all background tasks (cascade control). Call this when the parent session ends.
Trait Implementations§
Source§impl Attributable for DelegateTool
impl Attributable for DelegateTool
Source§impl Tool for DelegateTool
impl Tool for DelegateTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
Auto Trait Implementations§
impl Freeze for DelegateTool
impl !RefUnwindSafe for DelegateTool
impl Send for DelegateTool
impl Sync for DelegateTool
impl Unpin for DelegateTool
impl UnsafeUnpin for DelegateTool
impl !UnwindSafe for DelegateTool
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more