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§
- Agent
Orchestrator - Agent Orchestrator - 主子智能体协调器
- Agent
Slot - Unified agent slot declaration — used for both standalone subagents and team members.
- Orchestrator
Config - Orchestrator 配置
- SubAgent
Config - SubAgent 配置
- SubAgent
Event Payload - SubAgent 事件 Payload(用于 a3s-event)
- SubAgent
Event Stream - SubAgent 事件流(过滤特定 SubAgent 的事件)
- SubAgent
Handle - SubAgent 句柄
- SubAgent
Info - SubAgent 信息(元数据)
- SubAgent
Wrapper
Enums§
- Control
Signal - 控制信号 - 主智能体发送给子智能体的指令
- Orchestrator
Event - Orchestrator 事件 - 统一的事件类型
- SubAgent
Activity - SubAgent 当前活动
- SubAgent
State - SubAgent 状态