Skip to content

Superagent BaseAI Agent 开发基座

基于 Eino 框架,YAML 声明式构建任意 AI Agent — 5 分钟上手

一分钟看懂核心流程

                    ┌─────────────────────────┐
                    │     YAML Agent 定义      │
                    │  (configs/agents/*.yaml) │
                    └────────────┬────────────┘
                                 │ fsnotify 热加载

┌──────────┐    HTTP SSE    ┌─────────────┐    OpenAI API    ┌───────────┐
│  Client  │ ──────────────▶│  Agent 引擎  │ ──────────────▶ │  LLM 模型  │
│(curl/Web)│ ◀──────────────│  (port 8888) │ ◀────────────── │(多模型路由) │
└──────────┘   A2UI 事件流   └──────┬──────┘                  └───────────┘

                    ┌──────────────┼──────────────┬───────────────┐
                    ▼              ▼              ▼               ▼
              ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────────┐
              │  Memory   │  │  Tools   │  │  Skills  │  │  Evolution   │
              │(4 后端)   │  │(MCP/内置) │  │(3 来源)  │  │ (本地 MySQL) │
              └──────────┘  └──────────┘  └──────────┘  └──────────────┘

支持的 Agent 类型

类型说明
chat_model_agent标准对话 Agent,可挂载工具,Eino ReAct 自动调用
deep_agent深度推理模式,支持多步规划
agentloop自主循环,多轮迭代直到 [DONE] 或达到 max_turns
supervisor多 Agent 协调者,通过 LLM 决策分发给 sub_agents
sequential顺序执行 sub_agents,前一个输出作为下一个输入
parallel并发执行所有 sub_agents,合并输出
plan_execute先规划后执行的多 Agent 模式
workflowDAG 图执行,拓扑排序 + 变量映射
eino_graph原生 Eino Graph,VS Code 插件可视化编排后注册

内置 Agent 案例一览(14 个)

开箱即用的典型 AI Agent 模板,参考 cloudwego/eino-examples 官方案例设计,覆盖所有主流 Agent 架构模式。

基础能力 — 单 Agent 场景

research-agent — 通用研究助手

字段
类型chat_model_agent
工具无(纯对话)
场景通用问答、信息整理、知识解释
yaml
spec:
  type: chat_model_agent
  system_prompt: "You are a helpful research assistant..."

react-tools-agent — ReAct 工具调用

字段
类型chat_model_agent + 3 工具
工具builtin/web_search + builtin/http_request + builtin/code_execute
场景需要搜索、API 调用或代码执行的复杂任务
模式Think → Act → Observe → Respond 循环
yaml
spec:
  type: chat_model_agent
  tools:
    - ref: builtin/web_search
    - ref: builtin/http_request
    - ref: builtin/code_execute

rag-knowledge-agent — RAG 知识问答

字段
类型chat_model_agent + search
场景基于文档检索回答问题,附带引用来源
特点搜索 → 分析 → 综合 → 引用来源
yaml
spec:
  type: chat_model_agent
  system_prompt: |
    Answer based on retrieved documents. Always cite sources.
    Never fabricate information not found in documents.
  tools:
    - ref: builtin/web_search

code-assistant — 自主编程循环

字段
类型agentloop(最多 15 轮)
工具builtin/code_execute + builtin/web_search
场景自主编码:分析需求 → 编写代码 → 执行验证 → 修复问题
完成信号输出 [DONE] 终止循环
yaml
spec:
  type: agentloop
  max_turns: 15
  tools:
    - ref: builtin/code_execute
    - ref: builtin/web_search

data-analyst — 数据分析

字段
类型chat_model_agent + code_execute
场景统计分析、数据清洗、趋势识别
输出Summary → Key Findings → Details → Recommendations
yaml
spec:
  type: chat_model_agent
  model:
    temperature: 0.1
  tools:
    - ref: builtin/code_execute
    - ref: builtin/http_request

多 Agent 编排 — 协作场景

team-supervisor — 团队 Supervisor

字段
类型supervisor(最多 8 轮)
子 Agentresearch-agent + code-assistant + react-tools-agent
场景复杂任务自动分派给专业子 Agent 协作完成
yaml
spec:
  type: supervisor
  sub_agents:
    - ref: research-agent
      role: Research and factual questions
    - ref: code-assistant
      role: Code writing and debugging
    - ref: react-tools-agent
      role: Web search and API calls
  orchestration:
    mode: supervisor
    max_rounds: 8

plan-execute-agent — 先规划后执行

字段
类型plan_execute(最多 10 轮)
子 Agentreact-tools-agent + research-agent
场景制定 3-7 步计划 → 逐步执行 → 动态调整
特点遇到新信息或阻塞时自动重新规划
yaml
spec:
  type: plan_execute
  sub_agents:
    - ref: react-tools-agent
    - ref: research-agent
  orchestration:
    mode: plan_execute
    max_rounds: 10

parallel-analysis — 并行多视角分析

字段
类型parallel
子 Agentresearch-agent(事实分析)+ react-tools-agent(技术分析)
场景同时从多角度分析,综合得出结论
yaml
spec:
  type: parallel
  sub_agents:
    - ref: research-agent
      role: "Factual analysis — data and evidence"
    - ref: react-tools-agent
      role: "Technical analysis — feasibility and trade-offs"

sequential-pipeline — 顺序流水线

字段
类型workflow(3 节点 DAG)
流程翻译 → 润色 → 校对
场景每步输出作为下一步输入的固定流程
yaml
spec:
  type: workflow
  workflow:
    nodes:
      - id: translate
        type: llm_call
        prompt: "Translate the text..."
      - id: polish
        type: llm_call
        prompt: "Polish the translation..."
      - id: proofread
        type: llm_call
        prompt: "Proofread for errors..."
    edges:
      - { from: START, to: translate }
      - { from: translate, to: polish }
      - { from: polish, to: proofread }
      - { from: proofread, to: END }

research-workflow — 研究报告流水线

字段
类型workflow(3 节点 DAG)
流程搜索 → 分析 → 格式化 Markdown 报告

人机协作 — 中断/审批场景

approval-agent — 安全确认

字段
类型chat_model_agent + interrupt
场景执行危险操作(删除、发送、支付)前暂停等待确认
恢复POST /api/v1/chat/resume 传入确认结果

approval-workflow — 审批工作流

字段
类型chat_model_agent + interrupt + tools
工具builtin/http_request + builtin/code_execute
场景完整审批门禁:识别敏感操作 → 暂停 → 确认/取消 → 执行/放弃
超时600 秒未确认自动过期
yaml
spec:
  type: chat_model_agent
  tools:
    - ref: builtin/http_request
    - ref: builtin/code_execute
  interrupt:
    enabled: true
    checkpoint_backend: memory
    timeout_seconds: 600

feedback-writer — 迭代写作

字段
类型agentloop(最多 8 轮)
场景生成内容 → 等待用户反馈 → 根据反馈修改 → 循环直到满意
输出每次修改说明变更原因和保留原因
yaml
spec:
  type: agentloop
  model:
    temperature: 0.7
  max_turns: 8

所有 Agent 定义在 backend/configs/agents/*.yaml,支持 fsnotify 热加载,修改后无需重启即生效。

快速体验

bash
# 1. 克隆项目
git clone https://github.com/Colin4k1024/superagent-base.git && cd superagent-base

# 2. 配置模型(编辑 backend/.env 填入你的 LLM 地址和 Key)
cp .env.example backend/.env

# 3. 启动(MySQL + Redis + Backend)
make dev

# 4. 对话
curl -N -X POST http://localhost:8888/api/v1/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"agent_id":"research-agent","session_id":"s1","message":"hello"}'

技术栈

选型
HTTP 框架Hertz (CloudWeGo)
LLM SDKEino (CloudWeGo)
模型提供商OpenAI / Claude / Gemini / DeepSeek / Ark / Ollama / Qwen
ORMGORM + MySQL 8.x
缓存Redis 7
可观测性OpenTelemetry + Prometheus + Grafana
前端React 18 + TypeScript + Vite 5 + Tailwind 3.4
部署Docker Compose / Kubernetes Helm

Released under the Apache 2.0 License.