Skip to main content

Module orchestrator

Module orchestrator 

Source
Expand description

Advanced SubAgent control plane.

This module is an advanced control-plane API for explicit SubAgent lifecycle management. Routine multi-agent composition should use the task / parallel_task delegation tools.

Broadcast-backed lifecycle APIs support:

  • monitoring SubAgent behavior, planning, and execution
  • dynamically controlling SubAgents: pause, resume, cancel, and inspect

§架构

AgentOrchestrator
    +-- spawn_subagent(SubAgentConfig)
    +-- AgentSession stream
    +-- broadcast OrchestratorEvent
    +-- pause/resume/cancel control signals

§使用示例

use a3s_code_core::orchestrator::{AgentOrchestrator, SubAgentConfig};

// Create a control plane backed by a real Agent.
let agent = std::sync::Arc::new(a3s_code_core::Agent::from_config(config).await?);
let orchestrator = AgentOrchestrator::from_agent(agent);

// Subscribe to all events.
let mut events = orchestrator.subscribe_all();

// Spawn a SubAgent.
let handle = orchestrator
    .spawn_subagent(
        SubAgentConfig::new("general", "Use glob to find Python files")
            .with_description("Analyze code")
            .with_max_steps(10),
    )
    .await?;

// Monitor events.
tokio::spawn(async move {
    while let Ok(event) = events.recv().await {
        println!("Event: {:?}", event);
    }
});

// Control the SubAgent lifecycle.
orchestrator.pause_subagent(&handle.id).await?;
orchestrator.resume_subagent(&handle.id).await?;

Structs§

AgentOrchestrator
Advanced SubAgent control plane.
OrchestratorConfig
Orchestrator 配置
SubAgentConfig
SubAgent 配置
SubAgentEventStream
SubAgent 事件流(过滤特定 SubAgent 的事件)
SubAgentHandle
SubAgent 句柄
SubAgentInfo
SubAgent 信息(元数据)

Enums§

ControlSignal
控制信号 - 主智能体发送给子智能体的指令
OrchestratorEvent
Orchestrator 事件 - 统一的事件类型
SubAgentActivity
SubAgent 当前活动
SubAgentState
SubAgent 状态