当前仓库保留三组维护中的 example:quickstart、production_coding_agent、multi_agent_support。
其余历史示例已下线 —— 把仓库收回到真实、可跑、可测的维护面,避免文档继续引用已经删除的历史目录。
除特别说明外,涉及真实 LLM 的 example 都默认使用 MiniMax 的 Anthropic-compatible 接口,
需要 MINIMAX_API_KEY(或等价的 LLM_API_KEY/LLM_API_BASE/LLM_MODEL)。
- 第一次跑仓库
- 先看
quickstart
- 先看
- 想看一个高设计密度、贴近真实应用分层的单 agent 例子
- 看
production_coding_agent
- 看
- 想看一个完整行使
agent_routerseam 的多 agent 应用(客服分诊)- 看
multi_agent_support
- 看
- 想学自定义 plugin / seam
- 先读 插件开发
- 再看
tests/fixtures/和examples/production_coding_agent/app/
用途:
- 最小 builtin-only setup
- 第一次确认 kernel 能跑
关键文件:
examples/quickstart/agent.jsonexamples/quickstart/run_demo.py
展示内容:
window_bufferreact- builtin search tool
- 同一个 session 下连续运行
运行:
uv run python examples/quickstart/run_demo.py相关验证:
uv run pytest -q tests/integration/test_runtime_from_config_integration.py用途:
- 演示一个高设计密度、production-style 的 coding agent
- 展示“SDK seam + app-defined protocol”如何一起工作
- 展示严格的本地验证路径
关键文件:
examples/production_coding_agent/agent.jsonexamples/production_coding_agent/run_demo.pyexamples/production_coding_agent/run_benchmark.pyexamples/production_coding_agent/app/examples/production_coding_agent/workspace/examples/production_coding_agent/outputs/
展示内容:
- task packet assembly
- persistent coding memory
- filesystem boundary
- safe tool execution
- local follow-up semantics
- structured delivery artifacts
- benchmark-style local evaluation harness
它不是在宣称“本地测完就能直接投入市场”,而是在示范:
- 一个可成长的 coding agent 应该怎样分层
- 什么该放 seam
- 什么该放 app protocol
- 怎样把验证写成可复现的集成测试
运行:
uv run python examples/production_coding_agent/run_demo.pyBenchmark:
uv run python examples/production_coding_agent/run_benchmark.py相关验证:
uv run pytest -q tests/integration/test_production_coding_agent_example.py用途:
- 演示一个完整行使
agent_routerseam 的多 agent 应用 - 客服分诊场景:concierge → refund_specialist / tech_support → account_lookup
- 覆盖
agent_router规范的每一条契约:delegate/transfer、三种session_isolation模式、max_delegation_depth限制、AgentNotFoundError、default_child_budget兜底、metadata["handoff_from"]传播
关键文件:
examples/multi_agent_support/agent_mock.json— 离线 mock 配置(四个 agent)examples/multi_agent_support/agent_real.json— 真实 LLM 配置(Anthropic-compatible)examples/multi_agent_support/app/deps.py—SupportDeps(CustomerStore+TicketStore+trace)examples/multi_agent_support/app/plugins.py—ToolPlugin子类(lookup、router-bound、action)examples/multi_agent_support/app/protocol.py— pydantic 信封(CustomerIntent、TicketDraft、DelegationTraceEntry)examples/multi_agent_support/scenarios.py— demo 和集成测试共享的四个场景函数examples/multi_agent_support/run_demo_mock.py— 离线演示(无 API key)examples/multi_agent_support/run_demo_real.py— 真实 LLM 演示
展示内容:
agent_router.delegate的三种session_isolation模式(shared / isolated / forked)agent_router.transfer的 handoff 语义 +HandoffSignal捕获- 嵌套 delegation 的 depth 传递(通过
RunRequest.metadata) - 错误路径:
DelegationDepthExceededError与AgentNotFoundError - 如何把 app-defined 协议(deps、pydantic 信封、trace 日志)叠在 SDK seam 之上
运行:
# 离线 mock(CI 默认路径)
uv run python examples/multi_agent_support/run_demo_mock.py# 真实 LLM(需要 .env)
cp examples/multi_agent_support/.env.example examples/multi_agent_support/.env
# 编辑 .env 填入 LLM_API_KEY / LLM_API_BASE / LLM_MODEL
uv run python examples/multi_agent_support/run_demo_real.py相关验证:
uv run pytest -q tests/integration/test_multi_agent_support_example.py进一步阅读:multi-agent-support-example —— 四个场景逐个走,每个场景标注它行使了 agent-router 规范的哪条契约。
虽然当前 repo 不再保留一堆独立 demo 目录,但”怎么自定义”并没有消失,主要参考面是:
tests/fixtures/custom_plugins.pytests/fixtures/runtime_plugins.pytests/unit/test_plugin_loader.pytests/unit/test_runtime_orchestration.pyexamples/production_coding_agent/app/openagents/plugins/builtin/tool_executor/filesystem_aware.py— filesystem 执行策略示例(FilesystemAwareToolExecutor,展示evaluate_policy()的结构)openagents/plugins/builtin/pattern/react.py—ReActPattern源码,展示resolve_followup()和repair_empty_response()的实际调用点
如果你想按最有效的顺序熟悉当前仓库,推荐:
所有维护中示例都有配套的集成测试:
# 运行全部集成测试
uv run pytest -q tests/integration/该示例展示 post-seam-consolidation(2026-04-18)的扩展方式如何在一个真实任务里串起来。
| 机制 | 实现位置 | 作用 |
|---|---|---|
自定义 tool_executor |
examples/research_analyst/app/executor.py::SandboxedResearchExecutor |
继承 SafeToolExecutor,覆写 evaluate_policy():内嵌 CompositePolicy AND-组合 filesystem + network allowlist;execute() 委托给 RetryToolExecutor(inner=SafeToolExecutor) 实现重试 + 超时 |
pattern 子类 + resolve_followup() 覆写 |
FollowupFirstReActPattern(examples/research_analyst/app/followup_pattern.py) |
继承 builtin ReActPattern,加载 followup_rules.json 后在 resolve_followup() 里做 regex → 模板本地解析;builtin ReActPattern.execute() 会先调用它短路 LLM |
session |
builtin jsonl_file |
全部 transcript / artifact / checkpoint 落盘到 sessions/<sid>.jsonl;重启后可重放 |
events |
builtin file_logging |
所有事件追加到 sessions/events.ndjson,便于审计 |
pattern 层用的是 FollowupFirstReActPattern(examples/research_analyst/app/followup_pattern.py),
只重写 resolve_followup() 即可。builtin ReActPattern.execute() 负责在 LLM loop 之前调用它。
与旧 seam 不同,follow-up 的调用点现在由 kernel 内部负责而不是 app 层显式调用。
HttpRequestTool对 5xx 不抛:工具内部吞掉了 HTTP 错误码并返回{"success": false, "error": "..."},SafeToolExecutor不会看到异常——所以"503 → 重试"走不通。示例的 stub 改为前两次 sleep 超过执行器超时,才真正触发ToolTimeoutError,让retrybuiltin 实际生效。- ReAct 每轮只调一次工具:builtin
reactpattern 一轮只允许一个 tool_call;多工具编排需要在 app 层的 pattern 里自己做。
位置:examples/pptx_generator/。7 阶段交互式向导(意图 → 环境 → 研究 → 大纲 → 主题 → 切片 → 编译QA),基于 Rich + questionary 的 TUI,默认通过 Tavily MCP 联网研究。
- 安装:
uv add "io-openagent-sdk[pptx]" - 运行:
pptx-agent new --topic "..."或pptx-agent resume <slug> - 查看已保存的用户偏好:
pptx-agent memory list - 删除偏好:
pptx-agent memory forget <id> - 回放已完成的运行:
openagents replay outputs/<slug>/events.jsonl(每次new/resume都会落盘 NDJSON 事件流,敏感字段自动脱敏) - 详细 CLI 说明:
docs/pptx-agent-cli.md(EN)
7 阶段的交互细节——意图逐字段编辑、大纲增删改重排、主题 3–5 候选图库 + 自定义编辑器、切片 schema 校验-重试 ≤2-fallback 到 freeform、跨会话偏好写回——详见 CLI 指南。
MCP 连接模式选型:研究阶段一次 agent run 会对同一个 Tavily MCP server 发起多次工具调用。把 mcp 工具的 config.connection_mode 从默认的 per_call 改成 pooled,可以让 N 次调用只 fork 一次 node 子进程,大幅降低延迟与资源占用。对外部服务不稳定或经常崩溃的场景,仍然建议保持 per_call 以利用 cancel-scope 隔离。对应的 connection_mode: "pooled" 示例:
{
"id": "tavily_mcp",
"type": "mcp",
"config": {
"server": {"command": "npx", "args": ["-y", "tavily-mcp"]},
"connection_mode": "pooled",
"probe_on_preflight": true
}
}开启 probe_on_preflight 后,mcp 未安装 / npx 不在 PATH / tavily-mcp 启动就崩溃等问题会在 agent 第一轮循环之前就被 runtime 翻译成 stop_reason=failed 的 RunResult,避免"LLM 先规划了再失败"的浪费。