memtomem-memory for Hermes Agent
A Hermes memory provider backed by memtomem. On each user turn it looks up your memtomem
long-term memory and gives Hermes the most relevant notes as context for that turn, without
the model having to call a tool. If you turn it on, it also copies what Hermes saves in its
built-in memory (MEMORY.md / USER.md) into memtomem. It uses the memtomem MCP server you
already run in Hermes; it starts no server of its own.
plugin.yaml is generated by tools/render_plugin_assets.py from
packages/memtomem-plugin-assets/contract.toml; __init__.py and this README are
hand-written.
What it does and does not do
- It recalls. On every non-trivial user turn (not greetings, acknowledgements or slash
commands) it searches memtomem for the turn's message and injects the results under a
one-line heading, "Recalled from memtomem". By default that is up to five results in at
most 4,000 characters of bullets, not counting the heading (see Settings). - Recall does not write. It adds no tools for the model, does not save conversations,
extracts nothing and adds no line to the system prompt. Saving notes is what the memtomem
MCP tools are for. - It mirrors Hermes's built-in memory only when you set
mirror_writes: true(off by
default; see Mirroring Hermes's built-in memory). - It waits for the search at most 300 ms by default (
budget_ms). A search that takes
longer is not used for that turn, but it is not cancelled: the call keeps running in the
background and its late result is discarded.rpc_timeout_seconds(10 s by default) is
the timeout the provider passes to Hermes's MCP call, not a deadline for the whole
background call, which first reads Hermes's config and prepares the call. Until the call
ends it holds the entry's one recall slot (see
Sharing the connection with the model). When
the provider shuts down it detaches from a call in flight rather than cancelling it.
Requirements
- Hermes Agent 0.21.5 or later, with MCP support (the
hermes-agent[mcp]extra).
plugin.yamldeclares this floor asrequires_hermes. - A Hermes MCP entry named
memtomemthat runs memtomem 0.6.8 or later: either the memtomem
plugin frompackages/memtomem-hermes-plugin, or your ownmcp_servers.memtomementry in
config.yaml. Earlier memtomem releases do not confirm that a search records nothing, and
this provider refuses to use them. - Mirroring needs memtomem 0.7.8 or newer, whose
mem_do(action="version")lists
hermes_mirror. With an older server, recall works as before and mirroring stays off
with one warning. - Git on
PATH, for the commit lookup under Install.
Install
Install from this repository, pinned to the commit of a memtomem release tag. Hermes
(0.21.5) takes a full 40-character commit SHA for --ref and refuses a tag name such as
v<version>, so look the commit up first:
git ls-remote --exit-code https://github.com/memtomem/memtomem "refs/tags/v<version>" "refs/tags/v<version>^{}"
The command prints one line for a lightweight tag and two for an annotated one; no output
and exit status 2 mean there is no such tag. Copy the SHA at the start of the line that ends
in ^{} if there is one, otherwise of the only line, and install at it:
hermes plugins install "https://github.com/memtomem/memtomem#packages/memtomem-hermes-memory" --ref <commit-sha>
In a terminal the install asks Enable 'memtomem-memory' now? [y/N]; when it does not ask, or
you answer no, it says "Plugin installed but not enabled" and suggests
hermes plugins enable memtomem-memory. A memory provider needs neither: on Hermes 0.21.5 it is
active once memory.provider names it. The exception is a provider listed under
plugins.disabled, where hermes plugins disable puts it: Hermes does not load it until
hermes plugins enable memtomem-memory takes it off that list.
memtomem-memory is also listed in the Hermes plugin catalog, so
hermes plugins install memtomem-memory installs without a commit lookup. It installs the commit
the catalog pins, which moves only when the catalog entry is updated and can trail the newest
memtomem release; to install a later release, use the commit lookup above.
Then select the provider and grant it access to the memtomem MCP entry in
~/.hermes/config.yaml (or your profile's config.yaml):
memory:
provider: memtomem-memory
plugins:
entries:
memtomem-memory:
mcp_allowlist: [memtomem]
hermes memory setup memtomem-memory asks whether to mirror Hermes's built-in memory (the
answer defaults to no, or to your earlier choice), then writes memory.provider and
memory.memtomem-memory.mirror_writes. An empty answer or end of input takes that default;
Ctrl+C stops setup before anything is written. Run without a terminal (cron, a gateway, piped
input) or with HERMES_NONINTERACTIVE=1, it writes nothing and prints the commands instead. It never writes the
mcp_allowlist grant: it prints the command, built from your configured server and keeping
the grants you already have. Add the grant yourself, in config.yaml as above or with
hermes config set plugins.entries.memtomem-memory.mcp_allowlist '[memtomem]'. Keep the
brackets: without them Hermes stores the string memtomem, which grants nothing.
Start a new session. Without the mcp_allowlist grant Hermes lets no plugin call an MCP
server, and the provider reports itself unavailable with the line to add.
What it calls and when
On every non-trivial user turn, without a model tool call, it makes one mem_search call
on the MCP entry named memtomem through Hermes's own MCP client, with record=False
(nothing is written to memtomem's access counts or query history) and rerank=False.
Before its first call, and again every 10 minutes and after any failed call, each session's
provider asks the server what it supports (mem_do(action="version")). A server that lists
them also gets namespace="!system" (search every namespace except memtomem's system ones,
even while the model has a memtomem session namespace open) and deadline_ms (the
rpc_timeout_seconds less one second, a budget for the server's own processing; past it the
server answers with a retryable error instead of results). An older server gets exactly the
call above. That question counts toward the entry's one call at a time; its answer never
resets the failure waits below, and a question that fails counts as one failure.
It owns no server. If the memtomem entry has not started yet, the first recall makes Hermes
start it, and that first turn gets no recall while memtomem loads its models (a few seconds).
The query is the turn's full message, and it goes to whichever server Hermes connects for
the memtomem entry (see Which entry it uses). The provider does not
check that server's transport or host: when the entry Hermes uses points at a remote server,
each recall call sends the message there, whatever that server's search configuration.
What that call reaches is whatever the entry's memtomem configuration reaches: its store,
any .env that entry lets memtomem load (the memtomem plugin's own entry loads none), and
the network paths that configuration enables. The memtomem
plugin's README lists those under "Network"
(packages/memtomem-hermes-plugin/README.md);
read it at the same release commit you installed.
Which entry it uses
- A
mcp_servers.memtomementry inconfig.yamlwins over the memtomem plugin's entry of
the same name, even when it is disabled and even when it pins an older memtomem. - One exception: Hermes drops a native entry that its MCP security check flags and uses the
plugin's entry instead. The provider does not repeat that check. It still reads the
dropped native entry'senabledandtrust, so it can refuse recall that Hermes would
have served through the plugin's entry. - The provider checks every answer. A server that does not confirm
"recorded": falseis
older than memtomem 0.6.8; recall stays off, with one warning in the log, until the entry
runs a newer release. Each such answer starts a wait as a failure does (15, 60, then 300 s
at the defaults below), and fixing and reloading the entry does not end the current wait:
recall tries the server again only after it. - A disabled entry, a missing entry or a missing
mcp_allowlistgrant turns recall off on
the next turn, with one warning, and nothing is called.
Mirroring Hermes's built-in memory
Off by default. With mirror_writes: true under memory.memtomem-memory (or yes at
hermes memory setup), every entry Hermes's built-in memory tool saves, replaces or removes
is sent to memtomem as one mem_do(action="hermes_mirror_apply") call on the same MCP entry.
What memtomem keeps, and where:
- One row per entry in memtomem's database, keyed by the entry's text, for each Hermes profile
and target (memoryforMEMORY.md,userforUSER.md). A removed entry keeps only its
key, not its text. The profile is identified by a hash; no path of yours reaches the store. - A Markdown file rendered from those rows,
hermes-mirror/<profile hash>/<target>.mdunder
the first of memtomem'smemory_dirs, indexed and searched like your other notes. memtomem
overwrites it on every change: edits you make to it are lost, and a deleted file comes back. - Every session of every profile on the same memtomem store can recall these entries, as it
can recall anything else in that store. - The server Hermes connects for the entry receives the entry text, the same as a recall query
reaches it (see What it calls and when).
How it behaves:
- Hermes's own store stays authoritative. memtomem keeps the newest write per entry, by the
time the provider saw it, so retries and two sessions writing at once converge. - Two limits come from what Hermes tells a provider, which is the entry's text and no stable
id. An entry whose text Hermes masked differently when it was saved than when it was later
replaced or removed is not found, and the old copy stays in memtomem; the provider logs it
once. Two Hermes processes of one profile changing the same entry within moments of each
other can be mirrored in the wrong order, which can leave a removed entry in memtomem. Later
writes do not reliably clean either case up: purge the target (below) and let Hermes write
again. - A replace or remove from a Hermes that does not report the entry it changed
(previous_content) is skipped, with one warning; identity is never guessed. - A new entry that matches one of memtomem's privacy patterns is refused and not stored. A
replacement that matches is refused too, and the entry it replaces is removed from the mirror. - Writes go out in order from a background worker, one at a time and through the same one call
per entry name as recall (see the next section). A write that memtomem refuses is dropped; a
write that fails or finds the server busy is tried up to three times, then dropped. The queue
holds 256 writes; more are dropped. Each kind of drop is logged once per profile. - Pending writes live only in memory. When a session ends, the provider tries for up to
rpc_timeout_secondsto send what is queued and drops the rest; a crash loses them. - A change memtomem accepted but could not render or index yet (the file is held by a privacy
check, or indexing failed) is kept: the provider asks for the file to be rendered again after
the first failure wait, and the next write renders it too. Until then a removed entry can
still be found by search. - The server's processing budget does not cover the wait for memtomem's database writer
(up to 5 s) or SQLite's own lock wait; a write whose budget ran out by then is refused, not
stored. - memtomem checks the file's location before writing (inside its first memory directory, not a
link, not excluded or read-only), but a directory replaced by a link while a write runs is not
caught, as for every memtomem writer.
Turning mirror_writes off stops new writes; it removes nothing. To remove a target's mirror,
turn mirroring off, end the Hermes sessions, then call
mem_do(action="hermes_mirror_apply", params={"owner": "<profile hash>", "target": "memory", "op": "purge", "ts": <now>}) on the memtomem server. The hash is the folder name under
hermes-mirror/; <now> is the current time in nanoseconds on the machine Hermes runs on
(python3 -c 'import time; print(time.time_ns())'), because memtomem compares it with the times
the provider stamped on its writes. That deletes every row stamped at or before <now>, rewrites
the file and its search entries without them, and refuses any write stamped earlier that is still
on its way; a write stamped later is kept, and the next write after it starts the target again. "op": "reconcile" (no ts) re-renders a target's file, for example
after it was edited or deleted by hand.
Sharing the connection with the model
Recall uses the same connection, call queue and circuit breaker as the model's own memtomem
tools, and so do mirror writes. To keep the provider from crowding those out, it:
- makes at most one call at a time per MCP entry name, recall and mirror writes together,
across every session and profile in the Hermes process. A turn that starts while another
session's call is still running gets no recall; a mirror write waits its turn; - waits 15 s after a failed call before trying again, then 60 s, then 300 s for every further
consecutive failure. A successful call resets the schedule. A failed mirror write counts as
a failure; an answer in which memtomem refuses a write or says it is busy does not, and
Hermes does not count it against the breaker either.
Hermes opens an entry's circuit breaker after three consecutive failed calls and then refuses
the model's calls to it too. At the default settings (a 10 s call timeout and the 15/60/300 s
waits above) recall alone reaches three failures only after about the times below. They are
estimates for these scenarios. They shrink with shorter waits, and with a shorter
rpc_timeout_seconds, which for a server that is not running counts only below 5 s:
- about 105 s of continuous failure, for a server that stalls or a call queue held by one
long model operation; - about 90 s, for an entry whose server is not running: each attempt fails only after Hermes
has waited up to 5 s for the connection; - about 60 s for a stalling server, or about 45 s for one that is not running, when another
profile's healthy server runs under the same entry name and its recall succeeds between every
two failures, which keeps each wait at 15 s. When the failing profile's turn comes first after
the first wait, its second failure is followed by the 60 s wait instead, as for a single
profile. During each of those waits the healthy profile's recall pauses too.
The next successful call on the connection closes the breaker again: a long model operation
such as a large mem_index finishing, a model call, or recall's own next attempt. When the
server stalls, recall is empty and the model may see Hermes's breaker message.
The first call after the server starts holds the entry's one recall slot while memtomem loads
its models, so every session's recall on that entry pauses for up to a few seconds.
Trust
Recall is refused while the memtomem entry is not trust: full: on an untrusted entry
Hermes would ask for approval on every turn. Hermes applies a changed trust value only after
/reload-mcp. Until then the provider and Hermes can disagree: after an entry that Hermes
loaded as untrusted is changed to trust: full, each recall attempt in a gateway chat posts an
approval request into that turn's chat. Hermes withdraws a request still unanswered when the
turn's agent run ends, and the provider counts a withdrawn request as a failed recall, which
starts a wait. Run /reload-mcp after changing trust; recall tries the server again once
the current wait ends.
Profiles
The store a profile's recall reads is the one that profile's memtomem entry selects,
through the entry's environment. Profiles whose memtomem entries are identical share one
connection and one store. For a separate store per profile, give each profile's entry its
own env (HOME or the MEMTOMEM_* paths).
On a shared connection, one profile's /reload-mcp interrupts the other's pending recall
call. That call holds the recall slot for up to 15 s (Hermes's wait for the restarted server)
and then starts the first wait, so at the default settings recall on that entry resumes about
30 s after the reload.
Recall runs one call at a time per entry name in the whole process, even for profiles with
separate servers under the same name. While one profile's server stalls, every profile's
recall on that name pauses for the stall plus one wait. That is the price of never adding
more than one failure per wait to a breaker.
How the model reaches memtomem
By default Hermes offers MCP tools to the model through its tool-search bridge
(tool_search / tool_call), not as mcp__memtomem__* tools. Recall does not depend on
that: it calls memtomem directly, even when a toolset filter hides memtomem's tools from the
model. It does not work when Hermes did not connect the entry at all, for example under a
--toolsets selection that leaves it out.
Settings
Optional, under memory.memtomem-memory in config.yaml. They are read when a session's
provider starts; a changed value applies to sessions started afterwards. An out-of-range
value falls back to its default with one warning.
| Key | Default | Range |
|---|---|---|
server | memtomem | the MCP entry name to call |
budget_ms | 300 | 50–5000 |
top_k | 5 | 1–20 |
max_chars | 4000 | 500–9000 |
rpc_timeout_seconds | 10 | 1–600 |
cooldown_seconds | 15 | 1–300 |
long_cooldown_seconds | 60 | cooldown_seconds–600 |
max_cooldown_seconds | 300 | long_cooldown_seconds–600 |
mirror_writes | false | true or false (or Hermes's yes/no words); anything else is off, with a warning |
A profile whose memtomem entry has another name needs server set to that name, and the
same name in mcp_allowlist.
Logging
The provider logs at DEBUG through Hermes's logging, under the logger memtomem_memory, one
JSON object per event: initialize, prefetch (outcome and hook time), probe, rpc_done
(chunk ids and sources), rpc_error, rpc_unparsed, rpc_incompatible, preflight,
on_session_switch, shutdown, and for mirroring mirror_applied, mirror_not_rendered,
mirror_rpc_error and one mirror_<reason> event per skipped or dropped write. No log line at
any level contains the text of your message or of a memory entry. Warnings name the
configuration key to change.
Compatibility notes
- Hermes 0.21.5 hands a memory provider a registration context without MCP access, so the
provider builds Hermes's documentedPluginContextitself to callcall_mcp. That
constructor is not part of Hermes's plugin compatibility contract;call_mcpis. - To tell whether a portable plugin supplies the
memtomementry, the availability check
reads Hermes'sget_plugin_manager().get_portable_mcp_servers(), which is not part of that
contract either. If the lookup fails, returns something unexpected or returns an empty mapping
(Hermes fills it during its own discovery), the check reports the provider available and
the per-turn check decides. - The profile hash comes from Hermes's public
hermes_constants.hermes_home_key. - Hermes supports Python 3.11 to 3.13; the provider uses the standard library only and is
tested on 3.11.
License
Apache-2.0.
README from the reviewed commit 6de8869; it updates when the author re-pins.

memtomem