跪拜 Guibai
← All articles
Agent · Open Source · Artificial Intelligence

Agent Harnesses Decoded: Pi, OpenCode, Hermes, and OpenClaw Compared

By 掘金安东尼 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Choosing an agent harness can change an LLM's behavior more than choosing the model itself, and this comparison gives developers a concrete map of the trade-offs: from lightweight terminal tools to always-on personal assistants, the architecture around the model determines what the agent can actually do.

Summary

Putting the same LLM into different agent harnesses produces wildly different agents, and a new illustrated guide by Maarten Grootendorst maps out exactly why. The guide walks through five frameworks: TinyAgent, a 600-line teaching harness; Pi, a minimal terminal-first harness with compaction and steering; OpenCode, a client-server harness with SQLite persistence and subagents; Hermes, a personal-assistant layer with self-learning skills; and OpenClaw, the largest, with 30+ chat channels, a heartbeat, and nightly dreaming.

Key design decisions differ sharply. Pi compacts context at 184k tokens and stores sessions in branchable JSONL. OpenCode adds an HTTP server and a Code Mode for scripted tool calls. Hermes separates MEMORY.md and USER.md, keeps a skill index, and runs a review agent to distill reusable skills after sessions. OpenClaw flushes memory to disk before compaction, uses hybrid retrieval with BM25 and embeddings, and runs a three-stage nightly dream to promote daily notes into long-term memory.

The guide argues that the harness matters as much as the model choice: the same LLM behaves completely differently depending on memory, tooling, and session handling. It also highlights a common thread: every framework still runs the same ReAct reasoning loop underneath.

Takeaways
— The same LLM placed in different harnesses becomes a completely different agent.
— TinyAgent is a 600-line teaching harness showing the core ReAct loop.
— Pi compacts conversation history when the context window reaches 184k tokens, keeping the last 20k tokens verbatim.
— Pi writes every turn to JSONL with id and parent pointers, enabling branching like git.
— Pi's edit tool changes single lines instead of rewriting whole files, and it truncates long logs to the last 2,000 lines.
— OpenCode uses an HTTP server and SQLite database to persist sessions, so work can resume from a web app after closing the terminal.
— OpenCode's Code Mode lets the LLM write a script to orchestrate multiple tool calls at once, an example of the CodeAct pattern.
— OpenCode switches between Build Mode and Plan Mode by changing one permission rule: in Plan Mode, only plan.md is editable.
— OpenCode spawns read-only subagents for read/grep/glob tasks, which return ~200 token summaries instead of filling the main context.
— Hermes has 58 self-learning skills and separates MEMORY.md (environment facts) from USER.md (user preferences).
— Hermes loads only YAML skill headers initially (~30 tokens) and fetches full details (~1,200 tokens) only when needed.
— Hermes runs a review agent after sessions with more than 10 tool calls to create or update reusable skills.
— OpenClaw routes all private DMs into one main session and isolates group chats in separate sessions.
— OpenClaw has a heartbeat that wakes the agent every 30 minutes to check HEARTBEAT.md for new tasks or alerts.
— OpenClaw performs a memory flush before compaction, writing daily markdown notes to disk.
— OpenClaw uses hybrid retrieval combining BM25 (weight 0.3) and dense embeddings (weight 0.7), with 30-day decay and MMR.
— OpenClaw runs nightly three-stage sleep (light, deep, REM) to consolidate daily notes into MEMORY.md.
Conclusions

Every production harness, no matter how complex, still uses the ReAct loop at its core; the differences are all in memory, tooling, and persistence.

OpenCode's Plan Mode shows that a simple permission restriction can replace a dedicated planning system as models get stronger.

Hermes's skill learning blends Voyager's growing skill library with Reflexion's self-reflection, making the agent better over time.

OpenClaw's heartbeat and dreaming mimic human sleep and proactive checking, turning an agent from a reactive tool into an always-on assistant.

The token consumption at session start reveals design philosophy: Hermes spends on tool schemas, while OpenClaw spends on workspace files and rules.

Concepts & terms
Agent Harness
The software layer surrounding an LLM that turns its tokens into actions. It includes prompt assembly, tool execution, session storage, and guardrails.
ReAct
A reasoning loop where the model alternates between reason, act, and observe until it has enough information to answer. It remains the foundation of all harnesses in the guide.
CodeAct
A pattern where the model writes executable code to orchestrate a sequence of tool calls, rather than making one tool call per turn.
Compaction
A technique to shorten conversation history by summarizing earlier turns, freeing up context window space while preserving recent verbatim tokens.
Agentic RAG
Retrieval-augmented generation where the agent itself decides when and what to search, often using hybrid retrieval methods like BM25 and embeddings.
BM25
A classic keyword-based ranking function used in information retrieval to score documents against a query.
MMR (Maximal Marginal Relevance)
A re-ranking method that reduces redundancy by selecting items that are both relevant to the query and different from already selected items.
Heartbeat
A periodic trigger, in OpenClaw every 30 minutes, that wakes the agent to check for new tasks or alerts according to HEARTBEAT.md rules.
Memory Flush
Writing agent memory to disk before compaction to preserve important information across session truncation.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗