Skip to main content

register_subagent_if_enabled

Function register_subagent_if_enabled 

Source
pub fn register_subagent_if_enabled(
    tools: ToolRegistry,
    config: &Config,
    provider: Arc<dyn ChatProvider>,
) -> ToolRegistry
Expand description

Register the unified Agent (sub-agent / team coordination) tool — plus the coordinator-side coordination tools (send_message, list_workers, task_create / task_get / task_list / task_output / task_stop / task_update) — on tools when config.subagent_enabled is true.

This is the single, channel-agnostic hook called by every agent-loop entry point (CLI run / loop, HTTP API, TUI) after they build their base tool registry and resolve their provider, so the Agent tool and the coordinator prompt injected by crate::system_prompt::assemble_system_prompt stay in sync across all surfaces. Returns tools unchanged when sub-agent is disabled.

The coordination tools share a single TaskRegistry and WorkerRegistry with the Agent tool, so a coordinator can dispatch a worker via agent and then inspect / message / cancel it. Without this wiring the coordinator prompt would advertise tools it cannot actually call.