1.9 KiB
1.9 KiB
title, date, tags
| title | date | tags | |||||
|---|---|---|---|---|---|---|---|
| Hermes 编排 Agent + Web 可观测性方案 | 2026-04-29 |
|
Hermes 编排 Agent + Web 可观测性方案
背景
Hermes 作为母 Agent 编排不同的子 Agent(Codex、Claude Code 等),但全部在后台运行,无法直观看到每个 Agent 的实时输出和进度。需要将后台 tmux session 暴露到 Web 前端观察。
方案:ttyd + tmux
ttyd(GitHub 31k+ stars)可以把任意终端程序变成 Web 页面,通过 WebSocket 实时推流。
架构
Hermes (编排大脑)
│
├─ tmux session codex1 ─── ttyd :8080 ──► http://localhost:8080
├─ tmux session claude1 ─── ttyd :8081 ──► http://localhost:8081
└─ tmux session codex2 ─── ttyd :8082 ──► http://localhost:8082
使用方式
# 启动 Agent 的 tmux session
tmux new-session -d -s codex1 -x 140 -y 40
tmux new-session -d -s claude1 -x 140 -y 40
# ttyd 暴露每个 session 到 web
ttyd -p 8080 tmux attach -t codex1 &
ttyd -p 8081 tmux attach -t claude1 &
# 浏览器打开
open http://localhost:8080 # 看 Codex
open http://localhost:8081 # 看 Claude Code
类似方案
- Wetty / Gotty — 与 ttyd 类似
- LangFuse / AgentOps — 专业 Agent trace 平台,但偏事后日志分析,非实时终端画面
文件握手通信
Agent 之间通过文件交换上下文:
/tmp/handoff.json # Codex 输出 → Claude Code 读取
/tmp/instruction.md # Claude Code 重注入指令 → 拉起新 Codex
/tmp/next_prompt.txt # 下一步指令
关键结论
- 不要 让 Agent 之间直接互相调用(失控)
- 要 用 Hermes 作为中央编排大脑
- 用文件作为 Agent 间通信协议
- ttyd 解决实时观察问题,浏览器多标签同时查看所有 Agent
来源:Hermes Agent 对话 (2026-04-29)