A model-agnostic, portable long-term MEMORY framework for AI agents.
cognis-hermes gives any AI agent — regardless of which LLM or runtime drives it — a
durable place to remember facts, observations, and decisions, and to recall the most
relevant ones later. It is deliberately small, dependency-free (Python standard library
only), and embeddable: a single SQLite file holds everything, and recall uses a
self-contained TF-IDF + cosine-similarity ranker, so there is no embedding API to call,
no vector database to run, and no network access required.
remember(text) -> persisted memory with metadata
recall(query) -> ranked list of the most relevant memories
hermes is model-agnostic, portable long-term memory for AI agents, backed by a local SQLite store. The DB path resolves from --db, then $HERMES_DB, then ./hermes_memory.sqlite.
-
Install:
pip install cognis-hermes # or: pip install -e . hermes --version -
Store a memory with optional tags and provenance:
hermes remember "Customer prefers email over phone" --tags crm,prefs --source intake-form -
Recall relevant memories for a query (top-K, optionally filtered by tag):
hermes recall "how should I contact the customer?" --limit 5 --tag crm -
Read / manage the store — list, fetch by id, inspect stats, or use
--jsonfor machine-readable output:hermes list --limit 50 --json hermes get 12 hermes stats
-
Wire it into an agent / automation — point all calls at a shared DB and expose the store to an MCP client via the
hermes-mcpconsole script:export HERMES_DB=/srv/agent/memory.sqlite hermes remember "deploy finished" --tags ops hermes-mcp # MCP server (stdio JSON-RPC) for Claude/other agents
Most agent "memory" implementations are bolted to a particular model provider, a hosted
embedding endpoint, or a heavyweight vector store. That couples your agent's long-term
memory to infrastructure you may not want and to a vendor you may not keep. hermes
takes the opposite stance:
- Model-agnostic. No LLM is required to store or retrieve. You can wire it behind GPT, Claude, Llama, a local fleet, or a rules engine — hermes does not care.
- Portable. The entire memory is one
.sqlitefile you can copy, version, diff, or ship between machines. Move it from a laptop to a server and your agent keeps its mind. - Stdlib-only.
sqlite3,math,re,json,argparse. Nothing topip installbeyond Python itself. Installs and runs anywhere Python runs. - Inspectable. Memories are plain rows. The ranking is plain math. You can read, audit, and reason about exactly why a memory was recalled.
This is a clean-room, standard-library reimplementation of the Hermes memory pattern —
the broadly-known approach of giving agents a model-agnostic, persistent store with
lexical/TF-IDF recall rather than provider-locked embeddings. We gratefully acknowledge
the wider ecosystem of agent-memory work that inspired this design: persistent
conversation/observation stores, retrieval-augmented memory, and the
remember/recall tool interface that many agent frameworks have converged on. The
classic TF-IDF and cosine-similarity techniques used here are long-established
information-retrieval methods. This package re-expresses those ideas in a minimal,
portable form for Cognis Digital agents; any resemblance to prior implementations is at
the level of shared, well-known patterns.
pip install -e .
# or, since it is stdlib-only, just run it in place:
python -m hermes.cli --helpRequires Python 3.9+.
from hermes import MemoryStore
mem = MemoryStore("agent_memory.sqlite")
mem.remember(
"The user prefers metric units and concise answers.",
tags=["preference", "units"],
source="onboarding",
)
mem.remember("Deployed the trading bot to paper mode on 2026-06-08.", tags=["ops"])
for hit in mem.recall("what units does the user want", limit=3):
print(f"{hit.score:.3f} {hit.memory.text}")
mem.close()# store a memory
python -m hermes.cli remember "User's favorite ticker is GEV" --tags watchlist,equities
# retrieve relevant memories
python -m hermes.cli recall "which stock does the user like" --limit 5
# list / inspect / forget
python -m hermes.cli list --limit 20
python -m hermes.cli get 3
python -m hermes.cli forget 3
python -m hermes.cli statsThe database path defaults to $HERMES_DB or ./hermes_memory.sqlite. Override with
--db /path/to/file.sqlite.
Hermes ships an MCP server over stdio that exposes
the memory to any MCP-aware client (Claude Code, IDE agents, etc.) using the standard
JSON-RPC framing. It exposes four tools: remember, recall, forget, and
list_memories.
python -m hermes.mcp_server --db agent_memory.sqliteExample client config (e.g. an MCP mcpServers block):
{
"mcpServers": {
"hermes": {
"command": "python",
"args": ["-m", "hermes.mcp_server", "--db", "/data/agent_memory.sqlite"]
}
}
}- Every stored memory is tokenized (lowercased, alphanumeric word splitting, optional stopword removal).
- Document frequencies are maintained so that TF-IDF weights can be computed.
- At query time the query is tokenized the same way, a TF-IDF vector is built for it, and memories are ranked by cosine similarity against that vector.
- Recency acts as a gentle tie-breaker/booster (configurable), so all else equal a more recent memory ranks slightly higher — useful for agents whose world changes over time.
This is intentionally lexical. It is fast, explainable, and needs no model. If you later
want semantic recall, the MemoryStore API is the same shape you would wrap around an
embedding backend.
hermes/
__init__.py public API surface (MemoryStore, Memory, RecallHit)
memory.py SQLite-backed store + TF-IDF / cosine recall
cli.py argparse command-line interface
mcp_server.py stdio JSON-RPC MCP server exposing remember/recall
pyproject.toml packaging (name: cognis-hermes)
tests/ stdlib unittest suite
python -m unittest discover -s tests -vflowchart LR
U[You / CI / Agent] --> R[hermes]
R --> O[Outputs & artifacts]
R --> M[MCP / JSON]
M --> AI[AI agents]
R --> S[Cognis Neural Suite]
Explore the suite → 🗂️ all tools · ⭐ awesome-cognis · 🔗 cognis-sources
hermes composes with the 300+ tool Cognis suite — JSON in/out and a shared
OpenAI-compatible /v1 backbone. See INTEROP.md for the
suite map, composition patterns, and reference stacks.
Forward hermes's findings to STIX/MISP/Sigma/Splunk/Elastic/Slack/webhooks via
cognis-connect. See INTEGRATIONS.md.
MIT. See LICENSE.
Built by Cognis Digital LLC. Part of the Cognis agent tooling family.