Agent 与自动化 5.0 · 必读 2026-11-30 · 文章

A Visual Guide to Agent Harnesses

Maarten Grootendorst 图解 agent harness:模型无状态,harness 负责生成提示、执行工具、存储会话、施加护栏。文章对比 TinyAgent(约600行教学版 ReAct)与四个生产框架Pi(10万+行,184k token 触发压缩、精确 edit、运行中转向)。OpenCode(共享服务器+SQLite 会话库,CodeAct 式 Code Mode 一段脚本编排全部工具调用)Hermes 与 OpenClaw(带聊天连接器的个人助理层)。结论:各家规模与取舍差异很大,核心都是同一套 reason-act-observe 循环加压缩、精确编辑、日志截断。

打开原文回到归档

A Visual Guide to Agent Harnesses

中文导读

Maarten Grootendorst 图解 agent harness:模型无状态,harness 负责生成提示、执行工具、存储会话、施加护栏。文章对比 TinyAgent(约600行教学版 ReAct)与四个生产框架Pi(10万+行,184k token 触发压缩、精确 edit、运行中转向)。OpenCode(共享服务器+SQLite 会话库,CodeAct 式 Code Mode 一段脚本编排全部工具调用)Hermes 与 OpenClaw(带聊天连接器的个人助理层)。结论:各家规模与取舍差异很大,核心都是同一套 reason-act-observe 循环加压缩、精确编辑、日志截断。

为什么值得关注

图解 agent harness:从600行教学版 TinyAgent 到 Pi/OpenCode/Hermes/OpenClaw 四个生产框架的同源 ReAct 循环与不同取舍

Key Points (from source)

  • Snapshots reviewed (with 30+ custom visuals): TinyAgent v0.1.1, pi v1.2.0, OpenCode v2.0.29, Hermes 0e427d7, OpenClaw v2026.10.3.
  • TinyAgent is the ~600-line educational ReAct baseline from the author's book; its core step loop fits in fewer than 20 lines of Python (reason -> tool call -> observe).
  • Pi (100K+ lines, terminal-only, four default tools read/write/edit/bash): compaction triggers at 184k tokens while keeping the latest 20k verbatim; sessions persist as JSONL with id/parent pointers so earlier turns can be reverted and branched like git; a surgical edit tool updates single lines; oversized tool logs are truncated to the last 2,000 lines plus a path, recoverable via agentic RAG; mid-run steering injects user queries between parallel tool execution (steer vs follow-up messages).
  • OpenCode adds an HTTP server and a SQLite session store (opencode.db) so a session survives closing the terminal and resumes from any client; Code Mode (CodeAct) lets the model write one script that chains tool calls instead of one call per turn; Plan Mode is implemented by simply blocking the edit tool except plan.md; read-like tasks (read/grep/glob) are delegated to subagents that return only summaries.
  • Hermes adds the personal-assistant layer: chat gateways (Slack/WhatsApp), 50+ tools and 50+ bundled skills, USER.md/MEMORY.md personalization, and a review agent that triggers after sessions with 10+ tool calls to distill reusable skills (author likens it to Voyager's skill library plus Reflexion-style reflection); subagents can run in parallel and merge summaries.
  • OpenClaw is the largest: 30+ chat channels with a Main/Group session privacy split, a 30-minute heartbeat wake-up driven by HEARTBEAT.md, a memory flush written to disk before compaction, hybrid BM25+embedding RAG with 30-day recency decay and MMR reranking, and nightly 'Scheduled Dreaming' (light/deep/REM stages) consolidating daily logs into MEMORY.md.
  • Side-by-side comparison: Hermes spends its system-prompt budget on 21 default tool schemas, while OpenClaw exposes only 7 core tools and spends on workspace files (SOUL.md, MEMORY.md, rules); all four production harnesses adopt compaction, surgical edits and log truncation over the same ReAct core loop.

English Summary

Maarten Grootendorst's visual guide dissects the agent harness: everything around a stateless LLM that creates prompts, executes tools, stores sessions and enforces guardrails. Comparing codebase scale, it walks from TinyAgent (a ~600-line educational ReAct harness from his book) through four production frameworks: Pi (100K+ lines; compaction at 184k tokens, surgical edit tool, mid-run steering via parallel tool execution), OpenCode (shared server plus SQLite session store, CodeAct-style Code Mode chaining tool calls in one script), Hermes, and OpenClaw (a personal-assistant layer with 30+ chat connectors). All four production harnesses share the same reason-act-observe core loop and adopt compaction, surgical edits and log truncation; what differs is scale, connectors, memory and guardrails.

来源与证据

元数据抓于 2026-12-02T12:22:13+08:00,AAIF content-fetcher 2026-12-02.