# nousresearch/hermes-agent-self-evolution architecture

> Architecture diagram of the GitHub repository nousresearch/hermes-agent-self-evolution, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nousresearch/hermes-agent-self-evolution
- Repository: https://github.com/nousresearch/hermes-agent-self-evolution
- Video tour (about a minute): https://gitdiagram.com/nousresearch/hermes-agent-self-evolution/video

## Overview

1. **Repository purpose and scope**
   - This is a self-evolution framework for Hermes Agent, focused on automatically improving agent assets through iterative evaluation and mutation.
   - The repo is organized around **Phase 1: skill-file evolution** today. The README shows later phases for tools, system prompts, and code, but those are mostly planned rather than implemented.

2. **Top-level orchestration flow**
   - The main entrypoint for the implemented path is `evolution.skills.evolve_skill`.
   - That flow appears to: load an existing skill from the Hermes Agent repo, build an evaluation dataset, run an optimizer loop, score candidates, enforce constraints, and emit the best variant for human review/PR creation.

3. **Core domain layer**
   - `evolution/core/` contains the reusable backbone of the system:
     - `config.py` for runtime settings and repo/path configuration.
     - `dataset_builder.py` for assembling eval cases.
     - `external_importers.py` for bringing in external session histories or other datasets.
     - `constraints.py` for guardrails and acceptance checks.
     - `fitness.py` for scoring candidate variants.
   - This layer is the main boundary between “raw inputs” and “evolution logic.”

4. **Dataset and evaluation data pipeline**
   - The README describes two eval sources: **synthetic** and **sessiondb**.
   - The dataset builder likely normalizes these sources into a common evaluation format used by the optimizer.
   - The `datasets/skills` and `datasets/tools` directories are present as storage roots for generated or cached evaluation data, even though they currently contain only placeholders.

5. **External import boundary**
   - `evolution/core/external_importers.py` is the integration point for non-local data.
   - Based on the README, this likely covers imported execution traces or session history from external systems such as Claude Code, Copilot, or Hermes sessions.
   - Architecturally, this is the ingestion boundary where external behavior traces become optimization inputs.

6. **Constraint and safety gate layer**
   - `evolution/core/constraints.py` represents the hard acceptance criteria applied to candidate outputs.
   - The README names the effective gates: full test suite, size limits, caching compatibility, semantic preservation, and human review.
   - This layer separates “candidate generation” from “candidate acceptance,” which is important in the architecture because optimization is not allowed to directly publish unsafe variants.

7. **Fitness and selection**
   - `evolution/core/fitness.py` handles the scoring function used to compare variants.
   - In the repo’s model, fitness is not just test pass/fail; it is the mechanism that ranks candidates using evaluation results and likely execution-trace-derived signals.
   - This is the decision layer that feeds the Pareto/GEPA-style search process described in the README.

8. **Skill-specific implementation**
   - `evolution/skills/skill_module.py` likely defines the abstraction for a skill artifact and how it is loaded, mutated, and written back.
   - `evolution/skills/evolve_skill.py` is the operational CLI/script for the implemented evolution workflow.
   - This package is the main product surface today because Phase 1 targets **SKILL.md**-style assets.

9. **Other package namespaces**
   - `evolution/prompts/`, `evolution/tools/`, `evolution/code/`, and `evolution/monitor/` are separate namespaces for planned or future phases.
   - Their presence mirrors the roadmap in the README:
     - prompts for system prompt evolution,
     - tools for tool-description evolution,
     - code for implementation evolution,
     - monitor for observability and reporting.
   - Even if lightly populated now, they define the intended subsystem boundaries for future expansion.

10. **Reporting and artifacts**
   - `generate_report.py` and `reports/phase1_validation_report.pdf` indicate a reporting/validation artifact pipeline outside the main evolution loop.
   - This suggests the repo produces human-readable validation outputs alongside automated evaluation results.
   - That artifact boundary matters because the system is designed to support review before PR submission.

11. **Testing boundary**
   - `tests/core/` and `tests/skills/` cover the domain logic at the package boundaries rather than the whole end-to-end pipeline only.
   - Existing tests explicitly target constraints, external importers, and skill module behavior.
   - This signals that the architecture depends on stable contract-like behavior in the core layer before optimization runs are trusted.

12. **Runtime and tooling**
   - The project is a Python package configured via `pyproject.toml`.
   - The workflow is command-line driven and environment-variable configured, especially through `HERMES_AGENT_REPO`.
   - The README’s dependency on DSPy + GEPA is central to architecture: the repo does not train models locally; it orchestrates API-driven evolutionary search over text/code assets.

13. **System boundary with Hermes Agent**
   - This repo is not the Hermes Agent itself; it is an adjacent optimizer that reads and modifies Hermes Agent assets.
   - The external Hermes repo is the primary target system, while this repository is the controller/evaluator that produces candidate changes.
   - A clean diagram should show Hermes Agent as an external dependency, not as an internal module.

14. **Overall architectural shape**
   - The repo is best understood as a **pipeline architecture** with four main stages:
     1. ingest existing skill/tool/prompt/code assets,
     2. build eval datasets from synthetic or external session traces,
     3. generate and score candidate mutations with GEPA/DSPy,
     4. enforce constraints and emit reviewed artifacts.
   - The main boundary is between **candidate generation** and **candidate acceptance**, with the core package mediating both through dataset, fitness, and constraint modules.

Main entry points: [`evolution/skills/evolve_skill.py`](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/skills/evolve_skill.py) (Evolve skill), [`README.md`](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/README.md) (README), [`evolution/core/constraints.py`](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/constraints.py) (Constraints), [`evolution/core/external_importers.py`](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/external_importers.py) (Importers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_core["Core"]
  node_n_config["Config<br/>settings<br/>[config.py]"]
  node_n_dataset_builder["Dataset builder<br/>pipeline<br/>[dataset_builder.py]"]
  node_n_importers["Importers<br/>ingest"]
  node_n_constraints["Constraints<br/>guardrails<br/>[constraints.py]"]
  node_n_fitness["Fitness<br/>scoring<br/>[fitness.py]"]
end

subgraph group_g_skills["Phase 1"]
  node_n_skill_module["Skill module<br/>artifact model<br/>[skill_module.py]"]
  node_n_evolve_skill["Evolve skill<br/>cli pipeline<br/>[evolve_skill.py]"]
end

subgraph group_g_future["Future phases"]
  node_n_prompts["Prompts<br/>future namespace<br/>[__init__.py]"]
  node_n_tools["Tools<br/>future namespace<br/>[__init__.py]"]
  node_n_code["Code<br/>future namespace<br/>[__init__.py]"]
  node_n_monitor["Monitor<br/>observability<br/>[__init__.py]"]
end

subgraph group_g_data["Data and reports"]
  node_n_datasets[("Datasets<br/>storage")]
  node_n_reports["Reports<br/>artifact"]
end

subgraph group_g_tests["Tests"]
  node_n_tests_core["Core tests"]
  node_n_tests_skills["Skill tests"]
end

node_n_readme["README<br/>docs<br/>[README.md]"]
node_n_plan["Plan<br/>docs<br/>[PLAN.md]"]
node_n_hermes[("Hermes Agent<br/>external target")]

node_n_readme -->|"describes"| node_n_evolve_skill
node_n_readme -.->|"roadmap"| node_n_prompts
node_n_readme -.->|"roadmap"| node_n_tools
node_n_readme -.->|"roadmap"| node_n_code
node_n_config -->|"configures"| node_n_evolve_skill
node_n_evolve_skill -->|"loads"| node_n_skill_module
node_n_evolve_skill -->|"builds cases"| node_n_dataset_builder
node_n_dataset_builder -->|"uses"| node_n_importers
node_n_importers -->|"populates"| node_n_datasets
node_n_evolve_skill -->|"scores"| node_n_fitness
node_n_evolve_skill -->|"checks"| node_n_constraints
node_n_fitness -->|"feeds"| node_n_constraints
node_n_skill_module -->|"targets"| node_n_hermes
node_n_evolve_skill -->|"modifies"| node_n_hermes
node_n_constraints -->|"emits"| node_n_reports
node_n_evolve_skill -->|"outputs"| node_n_reports
node_n_tests_core -->|"covers"| node_n_constraints
node_n_tests_core -->|"covers"| node_n_importers
node_n_tests_skills -->|"covers"| node_n_skill_module
node_n_monitor -.->|"tracks"| node_n_reports
node_n_prompts -.->|"future target"| node_n_hermes
node_n_tools -.->|"future target"| node_n_hermes
node_n_code -.->|"future target"| node_n_hermes

click node_n_readme "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/README.md"
click node_n_plan "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/PLAN.md"
click node_n_config "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/config.py"
click node_n_dataset_builder "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/dataset_builder.py"
click node_n_importers "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/external_importers.py"
click node_n_constraints "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/constraints.py"
click node_n_fitness "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/fitness.py"
click node_n_skill_module "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/skills/skill_module.py"
click node_n_evolve_skill "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/skills/evolve_skill.py"
click node_n_prompts "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/prompts/__init__.py"
click node_n_tools "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/tools/__init__.py"
click node_n_code "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/code/__init__.py"
click node_n_monitor "https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/monitor/__init__.py"
click node_n_datasets "https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/datasets"
click node_n_reports "https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/reports"
click node_n_tests_core "https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/tests/core"
click node_n_tests_skills "https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/tests/skills"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_config,node_n_dataset_builder,node_n_importers,node_n_constraints,node_n_fitness toneBlue
class node_n_skill_module,node_n_evolve_skill toneAmber
class node_n_prompts,node_n_tools,node_n_code,node_n_monitor toneMint
class node_n_datasets,node_n_reports toneRose
class node_n_tests_core,node_n_tests_skills toneIndigo
class node_n_readme,node_n_plan,node_n_hermes toneNeutral
```

## Components

### Core

Reusable evolution primitives and decision logic

- [Config](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/config.py): settings · Runtime and repo/path configuration · `evolution/core/config.py`
- [Dataset builder](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/dataset_builder.py): pipeline · Assembles evaluation cases · `evolution/core/dataset_builder.py`
- [Importers](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/external_importers.py): ingest · Loads external session or trace data · `evolution/core/external_importers.py`
- [Constraints](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/constraints.py): guardrails · Acceptance checks and safety gates · `evolution/core/constraints.py`
- [Fitness](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/core/fitness.py): scoring · Ranks candidate variants · `evolution/core/fitness.py`

### Phase 1

Implemented skill-file evolution path

- [Skill module](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/skills/skill_module.py): artifact model · Loads, mutates, and writes skill assets · `evolution/skills/skill_module.py`
- [Evolve skill](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/skills/evolve_skill.py): cli pipeline · Main Phase 1 optimization workflow · `evolution/skills/evolve_skill.py`

### Future phases

Planned namespaces for later evolution targets

- [Prompts](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/prompts/__init__.py): future namespace · Planned system prompt evolution · `evolution/prompts/__init__.py`
- [Tools](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/tools/__init__.py): future namespace · Planned tool-description evolution · `evolution/tools/__init__.py`
- [Code](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/code/__init__.py): future namespace · Planned implementation evolution · `evolution/code/__init__.py`
- [Monitor](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/evolution/monitor/__init__.py): observability · Planned reporting and oversight · `evolution/monitor/__init__.py`

### Data and reports

Evaluation inputs and human-facing artifacts

- [Datasets](https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/datasets): storage · Generated evaluation data roots · `datasets`
- [Reports](https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/reports): artifact · Validation and review outputs · `reports`

### Tests

Boundary coverage for core and skill modules

- [Core tests](https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/tests/core): tests · Boundary tests for core logic · `tests/core`
- [Skill tests](https://github.com/nousresearch/hermes-agent-self-evolution/tree/main/tests/skills): tests · Boundary tests for skill module behavior · `tests/skills`

### Other components

- [README](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/README.md): docs · Project overview and roadmap · `README.md`
- [Plan](https://github.com/nousresearch/hermes-agent-self-evolution/blob/main/PLAN.md): docs · Implementation planning notes · `PLAN.md`
- **Hermes Agent**: external target · External repository being optimized

## Connections

- README → Evolve skill: describes · README documents the main implemented workflow
- README → Prompts: roadmap · README outlines future phases and namespaces
- README → Tools: roadmap · README outlines future phases and namespaces
- README → Code: roadmap · README outlines future phases and namespaces
- Config → Evolve skill: configures · Runtime settings and target repo path flow into the CLI
- Evolve skill → Skill module: loads · Main workflow operates on skill artifacts
- Evolve skill → Dataset builder: builds cases · Creates evaluation datasets for search
- Dataset builder → Importers: uses · Dataset assembly can incorporate external traces
- Importers → Datasets: populates · Imported data is normalized into dataset storage
- Evolve skill → Fitness: scores · Candidates are evaluated and ranked
- Evolve skill → Constraints: checks · Acceptance gates filter unsafe candidates
- Fitness → Constraints: feeds · Scores are interpreted through hard constraints
- Skill module → Hermes Agent: targets · Skill assets are read from and written toward Hermes Agent
- Evolve skill → Hermes Agent: modifies · Optimization produces candidate changes for the external repo
- Constraints → Reports: emits · Validation results support human review artifacts
- Evolve skill → Reports: outputs · Workflow produces reviewable artifacts
- Core tests → Constraints: covers · Tests protect the guardrail contract
- Core tests → Importers: covers · Tests protect external ingestion behavior
- Skill tests → Skill module: covers · Tests protect skill artifact behavior
- Monitor → Reports: tracks · Observability and reporting are planned around artifact outputs
- Prompts → Hermes Agent: future target · Prompt evolution will also target Hermes Agent assets
- Tools → Hermes Agent: future target · Tool evolution will also target Hermes Agent assets
- Code → Hermes Agent: future target · Code evolution will also target Hermes Agent assets
