Integrating with Hermes Agent and OpenClaw
Both integrations share one idea: Engram is a transparent proxy, so the agent never knows it exists. You change one base URL, and every conversation the agent has, on any channel, reads and writes one shared memory store. Prerequisites for everything below:
pip install engram-proxy
ollama pull qwen3:1.7b qwen3-embedding:0.6b
engram up # proxy on :11435, Ollama on :11434 behind it
Hermes Agent
Local model as the agent brain
Edit ~/.hermes/config.yaml and point the model block at Engram instead of Ollama:
model:
default: your-model # any Ollama model tag
provider: ollama
base_url: http://localhost:11435/v1 # was 11434
ollama_num_ctx: 65536
context_length: 65536
fallback_providers:
- provider: ollama
model: qwen3:1.7b
base_url: http://localhost:11435/v1
Then restart the gateway (hermes gateway restart) or just start a new hermes chat. That is the whole integration: every turn now gets memory recall before the model answers, and every exchange forms memories afterward.
- Ollama's /v1 endpoint ignores per-request
num_ctx, so bake it into a model variant:printf 'FROM qwen3:1.7b\nPARAMETER num_ctx 65536\n' > Modelfile && ollama create my-agent -f Modelfile - A 64k KV cache is ~6GB at f16 for qwen3-class models. Halve it with KV quantization before blaming anything else:
launchctl setenv OLLAMA_FLASH_ATTENTION 1andlaunchctl setenv OLLAMA_KV_CACHE_TYPE q8_0, then restart the Ollama app (measured: 7.5GB resident became 3.9GB with no visible quality change).
Cloud model as the agent brain, local memory
Hermes talks to several clouds over the Anthropic Messages protocol. Engram can sit in that path too, so a frontier model gets your local memory while embeddings and summarization stay on your machine:
# 1. run Engram with a cloud route for Anthropic-protocol traffic
ENGRAM_ANTHROPIC_UPSTREAM=https://api.minimax.io engram up
# 2. point Hermes's provider base URL at Engram's anthropic path
# (env var name depends on the provider; MiniMax shown)
echo 'MINIMAX_BASE_URL=http://127.0.0.1:11435/anthropic' >> ~/.hermes/.env
hermes gateway restart
Auth headers pass through untouched. The whole Messages surface follows the cloud upstream (count_tokens and batches included), so the SDK never goes split-brained. Added cloud cost is the injected block only, and big-prompt injection rides the newest message so the provider's prompt-cache discount survives.
Give the agent explicit memory verbs
Transparent injection works with any model. On top of that, Hermes agents can call Engram's memory tools directly (search, save, correct, pin, forget, profile), over the same store:
hermes mcp add engram-memory --command engram --args mcp
hermes gateway restart
Use the full path to the engram binary if it is not on the PATH Hermes launches with (which engram). Tool-calling reliability depends on the agent model; small local models see the tools but fumble the calls, while frontier-class models use them cleanly.
Performance notes from production
- Thinking mode burns turns. qwen3-family models think by default, and the /v1 endpoint cannot disable it per request. For an agent brain, bake suppression into your model variant's template (an empty think block in the generation prefix), or accept hidden reasoning tokens on every internal round.
- Prompt caching is everything for big agent prompts. Hermes system prompts run tens of KB. Engram places its memory block to preserve the prefix cache automatically; if turns are still slow every time, something upstream of Engram is churning the prompt head.
- Background work yields. Engram's summarizer checks for resident big models and steps aside, so it will not evict your agent's model mid-conversation. If summaries lag during heavy agent use, that is by design; they catch up at idle.
- Bootstrap from existing memory.
engram import ~/.hermes/memories/MEMORY.mdpulls the agent's bounded notes file into the uncapped store, backdated so nothing floods recall.
OpenClaw
OpenClaw mandates Ollama's native API for local models (its docs warn that /v1 breaks tool calling). Engram speaks that NDJSON protocol byte-faithfully, so the integration is one provider entry, keeping api: "ollama":
// openclaw.json (or your models config)
{
"models": {
"mode": "merge",
"providers": {
"engram": {
"baseUrl": "http://127.0.0.1:11435",
"api": "ollama",
"apiKey": "ollama-local"
}
}
}
}
- Auto-discovery keeps working. Engram passes
/api/tagsand/api/showthrough untouched, so OpenClaw sees the same models with the same capability flags. Its agent bar (tool support plus a 16k+ context) applies to the model, not to Engram. - num_ctx injection passes through. OpenClaw injects
options.num_ctxon native-API requests; Engram forwards request bodies unmodified apart from the memory block. - Raw completions are safe. OpenClaw's FIM and template completions hit
/api/generate, which Engram never injects into; only chat-shaped turns get memory. - MCP verbs work here too. OpenClaw consumes MCP servers; register
engram mcpas a stdio server to give it the explicit memory tools alongside its own.
Running alongside the agent's own memory
Both Hermes (MEMORY.md, USER.md) and OpenClaw (MEMORY.md, daily notes, its memory plugin slot) ship built-in memory. You do not have to choose:
- They stack cleanly. The agent's file memory is prompt-level; Engram is API-level, underneath everything. Each catches things the other misses.
- Engram filters agent plumbing. Memory-flush prompts, command-approval notices, and similar framework turns that arrive as user-role messages are classified as system provenance and never become memories. Third-party content the agent relays (group chats it observes) forms at reduced weight, cannot supersede your own statements, and can be quarantined entirely with
ENGRAM_QUARANTINE=observed. - Watch the caps. Agent memory files are typically bounded (Hermes enforces a character limit). Engram's store is not. When the agent's file fills up,
engram importthe file and let standing rules live in the agent's config (SOUL.md, AGENTS.md) rather than its memory file.
Verifying it works
engram why # the exact block injected into the last turn, score by score
engram list # watch traces form a few seconds after each exchange
engram stats # queue depth and degraded-recall counters
Open the observatory at 127.0.0.1:11435/engram/ui and leave it on a side screen: agent turns flare the memories they touch, and reinforced ones visibly migrate toward the core. The decisive test is always the same: tell the agent a fact on one channel, then ask about it obliquely from another. The answer can only come from Engram.