R441 · Agent principles and patterns › Harness building blocks

Same loop, four harnesses: a visual teardown of Pi, OpenCode, Hermes and OpenClaw

Read the original

agent-harnessagent-architectureagent-memorycontext-engineeringcompetitive-analysisteaching

Four production harnesses run the same ReAct loop; every meaningful difference is in where state lives, how context is shed, and who may write to memory.

What it is

A Visual Guide to Agent Harnesses by Maarten Grootendorst (co-author with Jay Alammar of An Illustrated Guide to AI Agents), published 2026-11-30 and shared on LinkedIn. It is a source-code teardown with more than 30 custom diagrams, built up from the book's 600-line educational TinyAgent to four production harnesses.

The guide pins its snapshots, which is the right practice for a fast-moving comparison: TinyAgent v0.1.1, pi v1.2.0, OpenCode v2.0.29, Hermes commit 0e427d7, OpenClaw v2026.10.3. Every claim below is as of those versions.

Thesis. Model weights are stateless; the harness is everything that builds the prompt, runs tools, stores sessions and enforces guardrails. All five run the same Reason-Act-Observe loop (TinyAgent's fits in under 20 lines of Python), so the same model in each yields four different agents. The differences sit in three places: where session state lives, how context is shed when the window fills, and how memory is written across sessions. The guide also draws a layer line: all four share a coding core (read, edit, execute), while Hermes and OpenClaw add a personal-assistant layer (chat connectors, personal memory, scheduled wake-ups), which is most of why they are larger.

Architecture side by side

One row per harness, smallest first. Figures are the guide's, read from source at the pinned snapshot.

HarnessShapeSession stateContext sheddingCross-session memoryDistinctive mechanism
TinyAgent~600 lines of Python, educational, local Gemma 4In-memory list; lost when the process exitsNoneNoneThe bare loop: reason, tool call, observe into memory
Pi~100K lines, terminal only, no server, four tools (read, write, edit, bash)Append-only JSONL tree with id/parent pointers; any turn can be forked like a git branchCompaction by LLM summary of older turns, last ~20K tokens kept verbatim; tool output truncated to the last 2,000 lines plus the file pathAGENTS.md-style filesSteering: a mid-run message is injected after parallel tools finish and before the next model call; follow-ups wait for the loop to stop
OpenCodeAbout Pi's size, HTTP server in front of the loopSQLite (opencode.db); each step reads history, runs one model pass, writes back, so any client can continue itRead-type work (read, grep, glob) delegated to a subagent that returns a ~200-token summaryDatabase sessionsCode Mode (CodeAct): one script chains several tool calls; Plan mode is a permission change, not a separate planner
HermesLarger; 21 default tools, 50+ bundled skills, chat gateway, pluggable sandboxesSessions plus memory filesCompacts earliest of the fourMEMORY.md (environment, tooling, lessons) split from USER.md (the person's preferences)A review agent runs after any session with more than 10 tool calls and writes or updates a skill; parallel subagents return per-file summaries
OpenClawLargest; 30+ chat channels, 7 core tools by defaultMain session (direct messages) kept apart from group sessions as a privacy boundaryMemory flush to disk before compaction, plus daily logsHybrid BM25 + embedding retrieval with 30-day recency decay and MMR rerank; nightly "dreaming" (light, deep, REM) consolidates logs into MEMORY.mdHeartbeat: a 30-minute wake-up governed by HEARTBEAT.md; the agent stays silent unless something crosses its threshold

The guide's comparison of the always-loaded prompt is the useful cost view: Hermes and OpenClaw spend about the same tokens before the first user word, Hermes on 21 tool schemas and OpenClaw on workspace files (SOUL.md, MEMORY.md, rules).

Tradeoffs

Failure modes and corrections

Two claims need qualifying against vendor documentation covered in earlier entries; the rest are not re-verified here and stand as the author's reading of source.

Review checklist

When choosing a harness, or reviewing one you built:

  1. Where does session state live, and can a run be resumed from a different client or forked from an earlier turn?

  2. What is the compaction trigger as a formula, not a number, and what survives it verbatim?

  3. When tool output is truncated, which end is kept, and is the full output still reachable by path?

  4. Which work is delegated to subagents, and does anything mark summarised text by origin before the parent acts on it with write or shell tools?

  5. Is "plan mode" a deny rule on every write path, including shell, or only on the edit tool?

  6. What may write to memory that loads in later sessions, who reviews it, and can a learned skill or fact be traced to the session that produced it?

  7. Does anything run without a human present (heartbeat, cron), and what untrusted input does it read when it does?

  8. How many tokens are spent before the first user word, and on what: tool schemas or workspace files?

  9. Which version did your comparison read, and when will you re-read it?

Sources: A Visual Guide to Agent Harnesses (Maarten Grootendorst, Exploring Language Models, 2026-11-30); LinkedIn post and its public comments.

Connections

See R441 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.