How nousresearch/hermes-agent-self-evolution works
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: evolve_skill.py Evolve skill · README.md README · constraints.py Constraints · external_importers.py Importers
Components 18
Core
Reusable evolution primitives and decision logic
- Config · Runtime and repo/path configuration
evolution/core/config.py - Dataset builder · Assembles evaluation cases
evolution/core/dataset_builder.py - Importers · Loads external session or trace data
evolution/core/external_importers.py - Constraints · Acceptance checks and safety gates
evolution/core/constraints.py - Fitness · Ranks candidate variants
evolution/core/fitness.py
Phase 1
Implemented skill-file evolution path
- Skill module · Loads, mutates, and writes skill assets
evolution/skills/skill_module.py - Evolve skill · Main Phase 1 optimization workflow
evolution/skills/evolve_skill.py
Future phases
Planned namespaces for later evolution targets
Data and reports
Evaluation inputs and human-facing artifacts
Tests
Boundary coverage for core and skill modules
- Core tests · Boundary tests for core logic
tests/core - Skill tests · Boundary tests for skill module behavior
tests/skills
Connections 23
- 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