Skip to main content

Module orchestrator

Module orchestrator 

Source
Expand description

Agent Orchestrator - 主子智能体协调器

基于 a3s-event 实现的统一事件总线,支持:

  • 实时监控所有子智能体的行为、规划和执行
  • 主智能体动态控制子智能体(暂停、恢复、取消、参数调整)
  • 可插拔的事件 provider(默认内存,可选 NATS)

§架构

AgentOrchestrator (主智能体)
    ↓ 订阅事件
┌───────────────────────────────┐
│   a3s-event EventBus          │
│ (Memory / NATS / Custom)      │
└───────────────────────────────┘
    ↑ 发布事件    ↓ 控制信号
SubAgentWrapper (子智能体)

§使用示例

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

// 创建 orchestrator (默认使用内存 provider)
let orchestrator = AgentOrchestrator::new_memory();

// 订阅所有事件
let mut events = orchestrator.subscribe_all().await?;

// 启动子智能体
let handle = orchestrator.spawn_subagent(SubAgentConfig {
    agent_type: "general".to_string(),
    description: "Analyze code".to_string(),
    prompt: "Use glob to find Python files".to_string(),
    permissive: true,
    max_steps: Some(10),
}).await?;

// 监控事件
tokio::spawn(async move {
    while let Some(event) = events.recv().await {
        println!("Event: {:?}", event);
    }
});

// 控制子智能体
orchestrator.pause_subagent(&handle.id).await?;
orchestrator.resume_subagent(&handle.id).await?;

Re-exports§

pub use crate::agent_teams::TeamRole;

Structs§

AgentOrchestrator
Agent Orchestrator - 主子智能体协调器
AgentSlot
Unified agent slot declaration — used for both standalone subagents and team members.
OrchestratorConfig
Orchestrator 配置
SubAgentConfig
SubAgent 配置
SubAgentEventPayload
SubAgent 事件 Payload(用于 a3s-event)
SubAgentHandle
SubAgent 句柄
SubAgentInfo
SubAgent 信息(元数据)
SubAgentWrapper

Enums§

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