Hermes Architecture Teardown: System-Level Agent Runtime for Sessions, Tools & Permissions
This article dissects the Hermes open-source agent runtime across nine architectural components—iteration loop, context compression, tool management, sub-agents, session persistence, prompt assembly, lifecycle hooks, and permissions—plus three extra subsystems: a multi-platform message gateway, isolated profile system, and first-class cron, revealing how Hermes builds system-level infrastructure for long-lived agents.
Hermes, from NousResearch, is one of the most capable open-source agent runtime frameworks. This analysis maps its implementation to a nine-part model for agent runtimes and highlights three additional subsystems that extend beyond that model.
Outer Iteration Loop
The core loop is familiar: call model, dispatch tools, append results, repeat until final response or interruption. Hermes stands out with its provider abstraction. The same runtime drives chat-completions APIs, Anthropic Messages, Codex Responses, out-of-process Codex app-server, and Bedrock. Tool-call formats and provider-specific quirks are normalized by transport adapters, making the model interface consistent at the loop level. This open approach is far more flexible for multi-model support than closed alternatives like Claude Code.
Context Management & Compression
Hermes implements a full compression pipeline rather than naive truncation. Earlier turns are summarized by an auxiliary model. Head and tail segments are protected by token budgets. Tool outputs older than a configurable threshold are pruned before summarization. The summary budget scales at roughly 20% of the compressed content, with a floor of 2,000 tokens and a ceiling of 12,000 tokens. This avoids overspending on tiny compressions while giving large compressions enough room to be useful.
Compression is also a session lifecycle event. When compression occurs, Hermes closes the current SQLite session row, creates a child session initialized with the summary, rotates the session ID, and records the parent-child lineage. Plugin context engines and memory providers are notified of the boundary shift. Multiple compressions yield a lineage chain instead of a repeatedly rewritten transcript—a unique trait among runtimes reviewed.
Skill & Tool Management
In Hermes, tool registration and tool exposure are separate concerns. Tools register into a central registry at import time. A separate toolset layer decides what the model actually sees in a given run. This exposure set is scoped by platform and scenario and can be further narrowed in delegated runs. A profile owns its own enabled scope.
This separation matters operationally: you can keep a broad library of installed tools while keeping the model-visible surface area small enough to control token cost and security risk.
Sub-Agent Management
The delegation primitive is solid. A sub-run gets its own task ID, its own terminal context, and returns a structured summary to the parent. Dangerous commands are denied by default in the delegation context, and recursive depth has a ceiling.
The current limitation is lifecycle ownership. Most sub-tasks still live under the parent call path; when the parent ends, children end with it. There is not yet a persistent, externally manipulable sub-run plane with independent control semantics.
Session Persistence & Recovery
This is where Hermes diverges most from editor-first runtimes. Session state lives in SQLite with FTS5 search and WAL journaling, plus fallback behavior for filesystems that cannot support WAL coordination. Sessions track turn provenance tags, parent-child lineage from compression splits, and metadata that the gateway can use for routing resolution before a model run.
This design treats sessions as runtime infrastructure, not just transcripts for recovery. CLI, messaging platforms, and cron jobs all plug into the same session plane. A message can be routed to the correct session before inference. Cron jobs can write into a session even with no active terminal.
Hermes also exposes a session-oriented session_search tool to the model for focused recall across historical sessions—a concrete example of pushing context-management decisions into the model loop rather than relying solely on static injection.
System Prompt Assembly & Project Context Injection
Hermes composes the system prompt in three explicit layers: stable, contextual, and volatile.
Stable layer carries identity (from SOUL.md when present), tool guidance for only enabled tools, skill index contents, environment hints (e.g., Tmux/container detection), and platform prompts.
Contextual layer reads project files from the current working directory ( AGENTS.md, CLAUDE.md, .cursorrules) and runs a prompt-injection scan before loading them.
Volatile layer carries memory snapshots, user configuration material, external memory provider blocks, and a one-line timestamp with model/provider metadata.
This layering is explicit in code, making invariants easier to reason about. The stable layer stays stable, the contextual layer stays sourced from the CWD, and the volatile layer changes per turn. Prompt reconstruction is bound to compression and related invalidation points, helping keep the prompt prefix cache-friendly across ordinary turns.
Lifecycle Hooks
Hermes provides two hook surfaces for different trust models.
Plugin lifecycle hooks run inside the runtime process and can block, rewrite, or pass through on events like pre/post tool call, gateway pre-dispatch, and approval request/response.
Filesystem-driven gateway hooks let users install shell or Python scripts that run on gateway startup, agent step, command trigger paths, etc.
Architecturally, both surfaces serve the same purpose: policy enforcement, auditing, and host-side side effects should execute independently of model cooperation.
What Hermes Adds Beyond the Nine-Component Model
Three subsystems stand out.
Message Gateway : Broad platform adapter surface (Telegram, Discord, Slack, WhatsApp, etc.) routing traffic through the shared session model. This feels like the UI paradigm validated in OpenClaw, built for users interacting with long-running agents.
Profile System : A profile is an isolated agent root directory. Two profiles on the same machine look like two different agents from a state and footprint perspective.
Cron as a First-Class Subsystem : Jobs are persistent, subject to the same permission machinery as interactive sessions, delivered via the gateway path, and scoped to profiles. This pushes unattended-operation concerns into the main architecture instead of leaving them as peripheral scripts.
Where Hermes Should Go Next
The obvious next step is moving from strong delegation to first-class orchestration. delegate_task already produces useful worker behavior and structured returns. What's missing is persistent sub-run control: run IDs, explicit lifecycle management, external manipulation, and cleanup semantics that survive parent completion. Hermes already has much of the substrate via session infrastructure and gateway routing. Promoting sub-runs to first-class control-plane objects is the natural architectural evolution—and a gap relative to OpenClaw's agent orchestration layer.
Conclusion
Hermes combines excellent execution quality with a powerful system foundation for open runtimes. It is likely one of the best open-model runtimes in the ecosystem. Its release cadence is staggering, and most of the hard infrastructure work is already in place. Hermes can already support a much wider range of long-lived agent workloads than typical coding runtimes handle today. The maturation of an orchestration layer on top of this base will be worth watching.
This analysis uses the author's previous article What Is an Agent Runtime Framework as a framework, and references Swarm Management of Agent Harnesses (Arize) and Anthropic's Managed Agents article.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
