Skip to content
AILinkDeepTech
Go back
AI Agents

Hermes Agent by Nous Research: Architecture, Self-Improving Loops, and MCP Integration

Abstract

Master Hermes Agent by Nous Research: explore the closed learning loop, hierarchical memory, progressive skill discovery, and multi-backend MCP integration.

Figure 1: Hermes Agent architectural lifecycle. Unlike stateless LLM agents that reset between turns, Hermes continuously persists state across three memory tiers, updates structured skill definitions, and indexes conversation trajectories via SQLite FTS5.

The Stateless Limitation of Contemporary Agents

Most agent frameworks (e.g., standard ReAct loops or chat-based CLI wrappers) operate under an episodic execution model: when a process terminates, the context window evaporates. Re-establishing project context, developer preferences, and tool idiosyncrasies requires manual re-prompting or bloated system prompt injection.

Hermes Agent, developed by Nous Research, addresses this limitation through an autonomous closed learning loop. The agent inspects its own execution trajectories, updates curated persistent memory buffers, discovers and compiles reusable skills, and indexes conversation turns into an embedded full-text search database.


Architectural Comparison

CapabilityStandard Stateless AgentAutoGPT / LangChain AgentHermes Agent
Session StateProcess-bound (Lost on exit)Vector DB ChunkingDual-Tier Markdown + SQLite FTS5
Skill SynthesisStatic / Pre-configuredScript GenerationProgressive Disclosure (agentskills.io)
Execution SandboxesLocal Host OnlyLocal Subprocess / Docker6 Backends (Local, Docker, SSH, Modal, Daytona, Singularity)
Memory Access OverheadN/AHigh (Embedding + Vector Search)Zero-Latency Prompt Injection + 20ms FTS5
Tool ProtocolCustom JSON SchemasOpenAI Function CallingDynamic Tool Registry + MCP Client

System Architecture

flowchart TD subgraph INGRESS["Ingress & Gateways"] CLI["Hermes CLI (cli.py)"] ACP["IDE ACP Server (JSON-RPC)"] GW["Multi-Channel Gateway\n(Telegram / Discord / Slack)"] end subgraph ENGINE["AIAgent Core (run_agent.py)"] RESOLVER["Provider & Model Router\n(OpenRouter, Anthropic, Bedrock)"] PROMPT_BUILDER["Three-Tier Prompt Assembler\n(Stable -> Context -> Volatile)"] TOOL_DISPATCH["Tool Dispatcher & Registry\n(70+ Tools / 28 Toolsets)"] COMPRESSOR["Context Window Compressor"] RESOLVER --> PROMPT_BUILDER PROMPT_BUILDER --> TOOL_DISPATCH TOOL_DISPATCH --> COMPRESSOR end subgraph STORAGE["Memory & State (hermes_state.py)"] MEM_TIER1[("Persistent Markdown\nMEMORY.md & USER.md")] MEM_TIER2[("SQLite + FTS5\nIndexed Session Store")] SKILLS_DIR[("Skills Hub\n~/.hermes/skills/*.md")] end subgraph EXEC["Execution Backends"] LOCAL["Local Host"] DOCKER["Docker Sandbox"] MODAL["Modal / Daytona Cloud"] MCP_CLIENT["MCP Servers (Stdio / SSE)"] end INGRESS --> ENGINE ENGINE <--> STORAGE TOOL_DISPATCH --> EXEC

Figure 2: Hermes Agent runtime stack. The AIAgent core resolves provider endpoints, compiles structured system prompts, and delegates tool execution to isolated backends or MCP servers while writing state updates to SQLite and Markdown stores.


Core Mechanisms & Mathematical Formulation

1. Three-Tier Hierarchical Prompt Assembly

To maximize KV-cache reuse with providers supporting prefix caching (e.g., Anthropic Prompt Caching), Hermes splits system instructions into static and dynamic partitions:

  • (Cached Prefix): Agent identity (SOUL.md), active tool JSON schemas, and Level-0 skill catalogs ().
  • (Semi-Static): Workspace context files (e.g., repository trees, README.md).
  • (Dynamic): Formatted MEMORY.md (), USER.md (), dynamic time, and current session metadata.

2. The Post-Turn Learning Loop

At the conclusion of each interaction turn , a background evaluation phase triggers:

sequenceDiagram autonumber actor User participant Agent as AIAgent Loop participant Tool as Tool Backend participant Mem as Memory Manager participant FTS as SQLite FTS5 Index User->>Agent: User Request Agent->>Tool: Execute Tool Calls Tool-->>Agent: Execution Output Agent-->>User: Final Response rect rgb(240, 240, 240) Note over Agent,FTS: Asynchronous Post-Turn Learning Loop Agent->>Mem: Inspect Delta (New Facts / User Preferences) alt Fact Worth Retaining Mem->>Mem: Update MEMORY.md / USER.md end Agent->>FTS: Ingest Turn & Token Embeddings end

3. Progressive Skill Disclosure

Skills adhere to the agentskills.io standard and load on-demand across three levels:

Level 0: skills_list()          --> Metadata Header (name, description, tags)  [~50 tokens/skill]
Level 1: skill_view(name)       --> Full SKILL.md Instructions & Workflows    [~500–2,000 tokens]
Level 2: skill_view(name, path) --> Supporting Scripts & Reference Files      [On-Demand]

Installation & Deployment

Quick Install

# Linux / macOS / WSL2
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
source ~/.bashrc

# Native Windows (PowerShell)
iex (irm https://hermes-agent.nousresearch.com/install.ps1)

Verify the environment:

hermes doctor
hermes --version

Configuration (~/.hermes/config.yaml)

# Model Provider Routing
providers:
  openrouter:
    api_key: ${OPENROUTER_API_KEY}
    api_mode: openai
    default_model: anthropic/claude-sonnet-4-6
  anthropic:
    api_key: ${ANTHROPIC_API_KEY}
    api_mode: anthropic
    prompt_caching: true

# Terminal Execution Sandbox
terminal:
  backend: docker          # local | docker | ssh | modal | daytona | singularity
  timeout: 180
  docker:
    image: "nikolaik/python-nodejs:python3.11-nodejs20"
    network: "bridge"      # none | bridge | host
    gpu: false

# Memory System & Approval Gates
memory:
  memory_char_limit: 2200
  user_char_limit: 1375
  write_approval: false    # Set true to enforce manual confirmation before saves

# MCP Server Definitions
mcp_servers:
  filesystem:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
  github:
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-github"]
    env:
      GITHUB_TOKEN: ${GITHUB_TOKEN}

Implementing Custom Skills

Create a structured skill directory inside ~/.hermes/skills/:

---
name: k8s-deploy
description: Validate, deploy, and inspect Kubernetes resources using kubectl and Helm
version: 1.0.0
platforms: [linux, macos]
metadata:
  hermes:
    tags: [kubernetes, helm, devops]
    category: devops
    requires_toolsets: [terminal]
---

# Kubernetes Deployment Workflow

## Deployment Procedure
1. Verify cluster connectivity:
   ```bash
   kubectl cluster-info
  1. Lint Helm charts before installation:
    helm lint ./chart/ -f values.yaml
  2. Execute atomic deployment:
    helm upgrade --install <release-name> ./chart/ --namespace <namespace> --atomic --timeout 5m

Rollback Protocol

If deployment fails, verify pod health and revert:

kubectl get pods -n <namespace> --field-selector status.phase!=Running
helm rollback <release-name> 0 --namespace <namespace>

---

## Subagent Delegation & Batch Trajectory Generation

### Parallel Workstream Execution via RPC

```python title="examples/subagent_delegate.py"
from __future__ import annotations

import json
from hermes.tools import delegate


def execute_parallel_audit() -> dict[str, str]:
    # Spawn isolated subagents with independent context budgets
    task_test = delegate(
        action="spawn",
        prompt="Execute pytest test suite in isolated container and report traceback",
        toolsets=["terminal"],
        backend="docker",
        timeout=300,
    )

    task_security = delegate(
        action="spawn",
        prompt="Run bandit and safety audit across all repository dependencies",
        toolsets=["terminal"],
        backend="docker",
        timeout=180,
    )

    return {
        "tests": task_test["output"],
        "security": task_security["output"],
    }

Research Trajectory Export

Hermes supports emitting structured ShareGPT / JSONL interaction trajectories for post-training and imitation learning:

python -m hermes.batch_runner \
  --input prompts/benchmark_tasks.jsonl \
  --output trajectories/sharegpt_v1.jsonl \
  --model anthropic/claude-sonnet-4-6 \
  --max-parallel 8

Production Security & Sandboxing Matrix

Deployment ProfileTarget EnvironmentSandbox BackendNetwork PolicyFile Access
Local DevWorkstationlocalHost AccessFull Filesystem
CI / Multi-UserShared ServerdockerIsolated BridgeMounted Directory Only
Serverless EvalsCloud Infrastructuremodal / daytonaEphemeral EgressRead-Only Root + /tmp
High SecurityUntrusted Webhooksdockernone (Offline)Ephemeral Scratch Memory

Troubleshooting Common Issues

1. Memory Buffer Saturation

  • Symptom: Agent logs MemoryLimitExceeded during turn evaluation.
  • Resolution: Adjust memory_char_limit in config.yaml or invoke /memory pending to prune obsolete facts.

2. FTS5 Index Desynchronization

  • Symptom: session_search fails to recall past conversations.
  • Resolution: Rebuild the SQLite full-text index via hermes doctor --reindex.

3. Docker Socket Permission Denied

  • Symptom: Tool execution fails with PermissionDenied: /var/run/docker.sock.
  • Resolution: Ensure the active user is in the docker user group (sudo usermod -aG docker $USER) and reload the shell.

Subscribe to Unlock the Rest

This section is exclusive to active subscribers. Support our work and unlock this article immediately.

Unlock this post and get unlimited access to all premium articles.

References

  1. Nous Research. (2025–2026). Hermes Agent Official Repository. GitHub.
  2. Anthropic. (2024). Prompt Caching: Accelerating Developer Workflows. Anthropic Engineering Blog.
  3. Model Context Protocol Authors. (2024–2026). Model Context Protocol Specification. modelcontextprotocol.io.
  4. AgentSkills Standard. (2025). Open Specification for AI Agent Toolkits. agentskills.io.


Cite this Article

@article{ailinkdeeptech2026hermesagentnousresearchselfimprovingaiagent2026tutorial,
  title={Hermes Agent by Nous Research: Architecture, Self-Improving Loops, and MCP Integration},
  author={AILinkDeepTech},
  journal={AILinkDeepTech AI Research Portal},
  year={2026},
  url={https://ailinkdeeptech.com/articles/hermes-agent-nous-research-self-improving-ai-agent-2026-tutorial}
}

Related Articles