Blog/Hermes Memory Tutorial
TutorialApril 9, 20268 min read

How to Add Memory to Your Hermes Agent

Hermes Agent is stateless out of the box. Plug in CortexDB as a memory provider and your agent remembers you -- across sessions, machines, and weeks.

The problem

Agents without memory are Groundhog Day machines. They relearn your preferences on every run, re-ask for context you already gave, and forget decisions five minutes after making them. The fix is a long-term memory layer the agent can write to and recall from on demand.

Hermes Agent was designed with this in mind. Its plugin system exposes a MemoryProvider ABC that any backend can implement. CortexDB is a natural fit: a hybrid-retrieval, event-sourced memory system purpose-built for AI agents.

The three-point memory cycle

A good memory provider does three things every turn:

  1. Inject relevant memory before the model sees the user's message. The model should already know what the user said last week when it writes this week's reply.
  2. Extract and persist what just happened after the reply. Every turn is a chance to learn something durable -- preferences, facts, decisions, frustrations.
  3. Prefetch likely next context between turns. Recall costs milliseconds, but doing it inline costs latency. Do it in the background instead.

The CortexDB provider implements all three.

Setup

Install the package:

pip install cortexdb-hermes

Export your CortexDB credentials:

export CORTEXDB_API_URL=https://api.cortexdb.ai
export CORTEXDB_API_KEY=cx_your_key_here

Activate it inside Hermes:

/memory use cortexdb

What it looks like in practice

Session 1 -- Monday:

You: I'm working on a Rust project called "orbit". It uses tokio and sqlx.
Assistant: Got it. What would you like help with?
You: Show me how to set up a connection pool.
Assistant: [shows tokio + sqlx PgPool example]

Session 2 -- Friday, new terminal:

You: Can you help me add a migrations command?
Assistant: Sure -- for your orbit project using sqlx, I'd recommend
sqlx-cli. Here's how to wire it into your tokio runtime...

The assistant already knows the project name, the language, and the stack. That context came from system_prompt_block() pulling the relevant Monday memories into the prompt before the model ran.

Tool calls the model can invoke

  • cortexdb_search -- natural-language search over long-term memory. The model calls this when it needs context it does not already have.
  • cortexdb_remember -- persist a specific fact, preference, or decision. Use when the user says “remember that...”
  • cortexdb_forget -- delete memories matching a query. Requires an audit reason.

Try it

Install the package, point it at your CortexDB instance, and give your Hermes agent a memory that actually sticks. Full docs are on the Hermes integration page.