目录

多智能体系统 — 11 个专业化 Agent 与分类编排

多智能体系统 — 11 个专业化 Agent 与分类编排

源码路径:/mnt/e/code/cc/omo-code/src/agents/ 核心文件:sisyphus/, builtin-agents.ts, dynamic-agent-prompt-builder.ts, types.ts 技术栈:Zod + Effect + 动态提示词生成


1. 概述

Oh-My-OpenAgent 的核心创新在于 11 个专业化 Agent,每个 Agent 针对特定任务类型和模型进行了优化。这些 Agent 不是简单的提示词变体,而是拥有独立的工具集、模型选择策略和委托规则。

Sisyphus (主协调者)
  ├── Prometheus (战略规划) ──→ Hephaestus (深度实现)
  ├── Atlas (Todo 编排) ──→ Sisyphus-Junior (类别执行)
  ├── Oracle (架构顾问) ──→ Momus (计划审查)
  ├── Librarian (文档搜索) ──→ Explore (快速 grep)
  └── Metis (计划差距分析)

2. Agent 总览

Agent模式主模型角色成本
Sisyphusprimaryclaude-opus-4-6主协调者,全局调度昂贵
Hephaestussubagentgpt-5.4自主深工作者,端到端完成昂贵
Prometheusprimaryclaude-opus-4-6战略规划者,访谈模式昂贵
Atlasprimaryclaude-sonnet-4-6Todo 编排者,任务执行中等
Oraclesubagentgpt-5.4架构顾问,只读咨询昂贵
Librariansubagentminimax-m2.7文档/OSS 搜索,多仓库分析便宜
Exploresubagentgrok-code-fast-1快速 grep,上下文理解便宜
Metissubagentclaude-opus-4-6计划差距分析,预规划昂贵
Momussubagentgpt-5.4计划审查者,吹毛求疵评审昂贵
Sisyphus-Juniorsubagent类别决定轻量级委托,类别路由变化
Multimodal-Lookersubagentgpt-5.4视觉内容分析,多模态昂贵

3. Agent 元数据

// src/agents/types.ts
export interface AgentDefinition {
  // 基本信息
  name: string
  description: string
  category: AgentCategory      // 'orchestration' | 'advisor' | 'exploration' | 'execution'
  cost: 'free' | 'cheap' | 'expensive'

  // 何时使用
  useWhen?: string[]           // 触发条件
  avoidWhen?: string[]         // 避免条件
  triggers?: string[]           // 关键词触发

  // 模型配置
  model: ModelConfig
  fallback_models?: string[]    // 回退模型链

  // 工具约束
  allowed_tools?: string[]
  disallowed_tools?: string[]

  // 提示词
  prompt: AgentPromptConfig
  variants?: Record<string, AgentPromptConfig>

  // 行为
  maxTurns?: number
  canDelegate?: boolean         // 能否委托给其他 Agent
}

4. Sisyphus — 主协调者

Sisyphus 是整个系统的中枢,采用 Sisyphus 隐喻(每日推石上山的希腊神话)来定义其行为哲学。

4.1 提示词结构

// src/agents/sisyphus/prompt.ts
export const SISYPHUS_PROMPT = `
You are Sisyphus, a master software engineer in the SF Bay Area.

Your job is not to do everything yourself — it's to coordinate a team of specialists.

## Your Team

- **Hephaestus**: Deep worker for goal-oriented execution
- **Prometheus**: Strategic planner for complex features
- **Atlas**: Todo orchestrator for multi-step tasks
- **Oracle**: Architecture consultant for high-level decisions
- **Librarian**: Documentation and code search specialist
- **Explore**: Fast codebase grep for understanding
- **Metis**: Plan gap analyzer for pre-planning
- **Momus**: Plan reviewer for critical feedback

## When to Delegate

| Situation | Agent |
|-----------|-------|
| Need deep implementation | Hephaestus |
| Need strategic planning | Prometheus |
| Need todo management | Atlas |
| Need architecture advice | Oracle |
| Need documentation lookup | Librarian |
| Need fast grep | Explore |
| Need plan gap analysis | Metis |
| Need plan review | Momus |

## Your Principles

1. **Delegate, don't do** — If a specialist can do it better, delegate
2. **Classify first** — Understand the request before choosing an approach
3. **Preserve context** — Pass enough context to workers
4. **Verify results** — Don't assume work is done until verified
5. **Iterate** — Small steps, early feedback

## Intent Gate (Phase 0)

Before classifying, detect the true intent:
- Is this a quick question? → Answer directly
- Is this a complex task? → Classify and delegate
- Is this a planning request? → Invoke Prometheus
- Is this a code exploration? → Invoke Explore
`

4.2 动态提示构建

// src/agents/dynamic-agent-prompt-builder.ts
export function buildSisyphusPrompt(config: Config): string {
  const sections: string[] = []

  // 1. 核心角色定义
  sections.push(SISYPHUS_PROMPT)

  // 2. 动态触发节(基于可用 Agent)
  sections.push(buildKeyTriggersSection(config))

  // 3. 工具选择表(按成本排序)
  sections.push(buildToolSelectionTable(config))

  // 4. 委托表(领域 → Agent 映射)
  sections.push(buildDelegationTable(config))

  // 5. 类别技能委托指南
  sections.push(buildCategorySkillsDelegationGuide(config))

  // 6. Agent 特定指南
  if (config.agents.explore?.enabled !== false) {
    sections.push(buildExploreSection(config))
  }
  if (config.agents.librarian?.enabled !== false) {
    sections.push(buildLibrarianSection(config))
  }
  if (config.agents.oracle?.enabled !== false) {
    sections.push(buildOracleSection(config))
  }

  return sections.filter(Boolean).join('\n\n')
}

4.3 模型解析 (4 步)

// Sisyphus 的模型选择遵循 4 步解析
function resolveAgentModel(config: Config, agent: AgentDefinition): string {
  // 1. 配置覆盖
  if (config.agents[agent.name]?.model) {
    return config.agents[agent.name].model
  }

  // 2. 类别默认模型
  if (config.categories[agent.category]?.default_model) {
    return config.categories[agent.category].default_model
  }

  // 3. Provider 回退链
  for (const fallback of agent.fallback_models ?? []) {
    if (isProviderAvailable(fallback)) {
      return fallback
    }
  }

  // 4. 系统默认
  return config.model ?? 'claude-sonnet-4-6'
}

5. 内置 Agent 分类

5.1 协调类 (Orchestration)

Prometheus — 战略规划者:

  • 6 阶段访谈模式
  • 需求提取和验证
  • 生成结构化计划

Atlas — Todo 编排者:

  • 使用 task() 工具管理任务
  • 动态 Agent 选择
  • 类别路由

5.2 顾问类 (Advisor)

Oracle — 架构顾问:

  • 只读咨询模式
  • XML 结构化输出
  • 决策框架:务实简约

Metis — 计划差距分析:

  • 意图分类:重构/构建/协作/架构/研究
  • 识别隐藏意图
  • AI slop 模式检测

Momus — 计划审查者:

  • 参考验证(文件存在、行号有效)
  • 可执行性检查
  • 只报告阻塞性问题

5.3 探索类 (Exploration)

Librarian — 多仓库文档搜索:

  • 4 阶段请求分类:概念 → 实现 → 上下文 → 综合
  • 集成 Context7、GitHub CLI、Web 搜索

Explore — 快速 grep:

  • 并行多角度搜索
  • 结构化结果输出

5.4 执行类 (Execution)

Hephaestus — 自主深工作者:

  • GPT-5.4 原生优化
  • 端到端任务完成
  • 不提前停止

Sisyphus-Junior — 轻量委托者:

  • 基于类别的模型选择
  • 最小化上下文开销

6. 分类系统

// 8 个内置分类
export const BUILTIN_CATEGORIES = {
  quick: {
    description: 'Quick questions and simple edits',
    default_model: 'claude-haiku-4',
    agents: ['explore'],
  },
  code: {
    description: 'Code implementation tasks',
    default_model: 'claude-sonnet-4-6',
    agents: ['hephaestus', 'sisyphus-junior'],
  },
  frontend: {
    description: 'Frontend development',
    default_model: 'claude-sonnet-4-6',
    agents: ['hephaestus', 'sisyphus-junior'],
  },
  backend: {
    description: 'Backend and API development',
    default_model: 'claude-sonnet-4-6',
    agents: ['hephaestus', 'sisyphus-junior'],
  },
  infra: {
    description: 'Infrastructure and DevOps',
    default_model: 'gpt-5.4',
    agents: ['oracle', 'hephaestus'],
  },
  data: {
    description: 'Data engineering',
    default_model: 'claude-opus-4-6',
    agents: ['oracle', 'hephaestus'],
  },
  security: {
    description: 'Security analysis',
    default_model: 'gpt-5.4',
    agents: ['oracle', 'momus'],
  },
  quality: {
    description: 'Testing and code quality',
    default_model: 'claude-sonnet-4-6',
    agents: ['momus', 'hephaestus'],
  },
}

7. 与 Claude Code / OpenCode 对比

维度Claude CodeOpenCodeOh-My-OpenAgent
Agent 数量7711
主协调Coordinator Mode (Prompt)Session TreeSisyphus (专用 Agent)
子 AgentWorker (同质)独立 Session专业化分工
模型选择单一模型单一模型多模型编排
委托机制SendMessageToolTaskToolDelegateTask + CallOmoAgent
分类路由8 个内置分类
模型回退Fallback 链 + 断路器

文档版本:v1.0 | 更新:2026-04-06