Skip to content

Learning Loop & Memory

源码版本v2026.7.20

Responsibility

This is the loop that makes Hermes "get better the more you use it". It distills each turn of conversation into: (1) skill evolution — creates/rewrites skills from experience (agent/learning_mutations.py); (2) memory — FTS5 full-text search + LLM summarization of past sessions (memory_manager), paired with Honcho's dialectical user modeling; (3) learning graph — organizes skills and memory into nodes/edges (agent/learning_graph.py); (4) background reviewbackground_review digests history in a thread and produces actionable rewrites. Skill rewrites ultimately flow back into the skill system for reuse in subsequent turns.

Key Files

Skill nodes & learning graph

Skill/memory rewrites

Memory management

Background review

Data Flow

  1. After each turn, the main loop hands a message snapshot to the background-review thread (agent/background_review.py:956).
  2. _digest_history (agent/background_review.py:122) summarizes recent history and produces candidate actions (create/rewrite skills, write memory).
  3. Skill rewrites go through edit_node:157; deletions go through delete_node:124, then _clear_skill_cache:200 clears the cache.
  4. Memory writes go through MemoryManager:354; after redaction (agent/memory_manager.py:164) an FTS5 index is built and an LLM summary is compressed.
  5. At the start of the next turn, build_memory_context_block (agent/memory_manager.py:337) weaves relevant memories into build_turn_context:268; skills are injected via agent/skill_bundles.py.
  6. The full learning graph is aggregated by build_learning_graph:254 for UI/debug display of skill↔memory links.

Summary

The learning loop turns "conversation" into "assets": background review distills experience into skills and memory, which are auto-injected on the next turn. The four-piece core — learning_graph (the graph), learning_mutations (rewrites), memory_manager (retrieval + redaction + summarization), background_review (async digestion). This is what lets Hermes "grow with the user" rather than act as a stateless LLM call.

Unofficial community learning site. Content based on the MIT-licensed NousResearch/hermes-agent source.