From OpenClaw to Hermes Agent: Rebuilding My Agent Architecture in Practice

    This article walks through a real-world migration from a master-slave agent setup to a standalone Hermes Agent execution architecture. It explains why the original master-slave design broke down under growing task complexity, then details the rebuild across three pillars: a four-layer memory system, a set of core governance documents (AGENTS.md, SKILLSPYRAMID.md, and YINYANG.md), and a dynamic skill pyramid. Readers will learn how to connect memory, documentation, and skill layering into a closed loop so an agent remembers what matters, stays constrained, and operates efficiently.

    1. Background: Why I Abandoned the Master-Slave Architecture

    Half a year ago I started building my own AI agent workflow. The initial design was simple: use a mature agent framework as the controller and mount Hermes Agent onto it as an MCP (Model Context Protocol) component. In other words, the main framework handled scheduling, routing, and user interaction, while Hermes only executed specific tasks—a classic “primary + auxiliary” model.

    This structure worked at first, but as task complexity grew, it exposed three fatal problems:

    1. Redundant scheduling chain: A single request had to be parsed by the main framework and then forwarded to Hermes. Context degraded badly across the two handoffs, and the agent often “forgot” what it had just been told to do.
    2. Fragmented memory system: The main framework had its own session memory, and Hermes had a separate execution memory layer internally. The two never communicated, so the same lesson had to be corrected twice.
    3. Difficult error recovery: Under the master-slave model, once the auxiliary component failed, the main framework could usually only retry or give up, lacking fine-grained fault tolerance.

    So I decided to promote Hermes to the center: make it a complete execution architecture in its own right, not an appendage to any framework. The rebuild below revolves around three pillars—the memory system, core documents, and skill layering.

    2. Memory System: From Three Layers to Four

    Hermes natively ships with three memory layers, which is already a solid design for an open-source agent:

    • Session layer: short-term context for the current conversation;
    • Experience layer: historical experience and user preferences retained across sessions;
    • Knowledge layer: retrieval-based references to external documents and materials.

    2.1 Adding a Fourth Layer: A Structured Memory Plugin

    On top of the original three layers, I integrated memos-plugin (an open-source memory management plugin whose repository can be found on GitHub), turning scattered “execution notes” into structured memory that is persistent, searchable, and cleanable.

    But integrating the plugin is not the key point—the key is connecting it with the core documents to form a closed loop. The reworked memory pipeline looks like this:

    1. conversation clustering → execution distillation → deep understanding (LLM second pass) → consolidation into Skills

    Concretely: every time the agent finishes a batch of tasks, the backend automatically clusters the raw conversations (grouped by task type and success/failure status), then uses an LLM to distill each cluster’s execution process—which steps were effective, which detours could have been avoided, and what strategy applies under which conditions. After deep understanding, the distilled result is finally solidified into a reusable Skill entry and written back to the skill library.

    2.2 The Dual Loop Between Memory and Skills

    The greatest value of this design is the bidirectional loop it creates:

    • Memory → Skills: scattered execution experience is compressed into high-density skill entries, upgrading memory from “record” to “capability”;
    • Skills → Memory: after a skill is executed, validated, and corrected, its usage results flow back into the memory layer to guide skill iteration.

    The end result: you don’t need to remember the details of every conversation (remember less), yet key experience and reusable strategies are retained reliably (remember firmly). This is my core goal for the memory system, and a plain standard for judging whether any memory architecture is sound.

    3. Core Documents: A Foundation More Important Than Skills

    This is the point I most want to emphasize: in the hierarchy of an execution architecture, core documents take priority over skill creation.

    Many developers are keen to pile up skills and write scripts while ignoring document constraints. But the essence of an agent is probabilistic reasoning—constrain it well and it moves in the direction you expect; constrain it poorly and it improvises, producing a pile of things nobody wants. Core documents are the agent’s “behavioral constitution.”

    3.1 AGENTS.md: The Hub Document for Global Workflow

    This is the primary document and the hub that connects all the others. Its structure should contain five modules:

    1. Execution flow and rules: the fixed path a task follows from receipt to completion, with input/output specs for each step;
    2. Skill orchestration mechanism: which tier of skill a given task type should invoke, and how to degrade when an invocation fails;
    3. Reporting format: a unified result output structure that keeps every delivery comparable and archivable;
    4. Memory system architecture description: letting the agent know “what memory is available, how to write to it, and how to query it”;
    5. Fault tolerance mechanism: tiered handling strategies for errors—ignorable, retry, escalate, or require human intervention.

    The value of a well-written AGENTS.md is this: even if the user throws in a single vague instruction, the agent can follow the established flow instead of “thinking from zero” every time.

    3.2 SKILLSPYRAMID.md: A Dynamic Skill Pyramid

    More skills is not better; they should be layered by invocation frequency and business value into a pyramid. Note in particular: the pyramid is a dynamic analytical view, not a static label set once and left untouched.

    My layering scheme:

    Tier Share Content Usage frequency
    Foundation 55% File operations, terminal commands, web access Daily
    General 30% Debugging, planning, code review Often
    Specialized 15% Machine learning, creative design, repository operations Specific scenarios
    Experimental 5% New skills, draft skills Try it out

    A matching promotion mechanism keeps the pyramid moving:

    • Experimental → Specialized: invoked more than 3 times within 30 days, with manual evaluation meeting the bar;
    • Specialized → General: validated across 3 or more different projects, with potential to be generalized.

    Conversely, skills that go unused for a long time should be demoted or retired, preventing the skill library from expanding endlessly and slowing down retrieval.

    3.3 YINYANG.md: A Decision-Boundary Table That Grows

    This is a table I designed by combining Daoist yin-yang thinking with set theory, addressing the long-standing problem of “how to make an agent remember preferences the user has corrected.”

    Core logic:

    1. User gives P (what they want)
    2. → Agent infers ¬P (what they don't want / where the boundary is)
    3. → Record it in the table
    4. → Before the next run, check the table and grasp the boundary instantly

    Three design principles:

    1. P and ¬P arise in pairs: yin and yang have no fixed primary or secondary, only semantic opposition. Recording “P” simultaneously records “¬P”;
    2. Reversible query: if a user preference one time falls on the “¬P” side instead, the original P automatically becomes the new “¬P”—no new entry needed, just query in reverse;
    3. Continuous growth: every time the user corrects the agent’s behavior, the agent summarizes and fills in a new entry itself, automatically avoiding the same issue in similar tasks next time.

    In practice, this table has brought the situation of “repeatedly correcting the same mistake” almost to zero.

    4. Closing Thoughts

    After the rebuild, Hermes had completely broken away from the original master-slave architecture and become an independent, self-consistent agent execution system. Looking back, my experience can be condensed into one sentence:

    Memory handles consolidation, documents handle constraints, and skill layering handles efficiency—connect all three, and an agent truly stands on its own.

    If you are building your own agent system, I suggest investing effort in the order “core documents → skill pyramid → four-layer memory.” Lay the foundation first, then talk about extending capabilities—this is the inevitable path for all agent architecture evolution.