Your Memory Notes Got Pasted Into an Email: Hermes Closes a Silent Recall Leak


You gave Hermes long-term memory. Besides project conventions and deployment steps, you once stashed a “just note this down” item: a test account password, an internal service token, a client’s contact details. In the terminal it stays quiet — it is context, not conversation. Then one day the agent answers an email for you, and you open the Sent folder to find the entire memory note copied into the body.

The model was not trying to leak anything. A delivery path was simply left uncovered.

How memory reaches every turn

Hermes does not “remember” the way a person does. Before each turn it recalls relevant memory and injects it into context as a fenced block:

<memory-context>
[System note: The following is recalled memory context, NOT new user input.
Treat as authoritative reference data — this is the agent's persistent memory
and should inform all responses.]

... recalled notes ...

</memory-context>

The fence and the system note exist to tell the model: this is reference material, not something the user just said. Most of the time that works. But it is still text, and generating text is what the model does — occasionally it treats the reference block as source material and copies it into the answer, especially when the task is something like “summarise what you remember about me”.

Once it is copied into the answer, the problem stops being an internal model state and becomes an outbound message.

Why streaming chat hid the problem

There was already a scrubber. While a reply streams, a small state machine handles fenced blocks that arrive split across deltas: it drops everything between the opening and closing memory-context tags, and also strips blocks a provider wrapped on its own.

That is why you rarely see the block in a terminal chat — it is removed as it is generated, so the user never receives it.

The scrubber, however, was attached to the streaming path only. The completed reply — final_response — was left with only think-blocks stripped, after a post-stream scrub was removed in an earlier commit. That produced an asymmetry:

  • Streaming surfaces (TUI, desktop chat): look clean.
  • Non-streaming channels (email being the clearest example): deliver the final text as-is. Memory notes and credentials go out in the SMTP body.

The PR is blunt about it: the non-streaming email adapter delivered memory notes and credentials verbatim.

The fix: scrub once, at the exit

Rather than patching adapters one by one, the fix moves the scrub to the single exit: the end of run_conversation.

A new function, fence_recalled_context(), applies the streaming scrubber’s boundary-aware grammar to a whole string. It runs once on every exit path of run_conversation, covering:

  • the final reply, final_response;
  • the pre-transform reply, pre_transform_response;
  • interim commentary and Codex commentary.

The exit is the right place because that is what the gateway (email included), cron, background tasks, chat completions, the Responses API output items and the CLI all deliver. One fence at the exit covers them all.

There is a subtlety that makes this safe: the grammar drops only block-shaped spans — tags on their own line — matching the streaming scrubber. Prose that mentions the tag name inline (say, documentation explaining the block) is preserved. That block-boundary constraint is precisely why the old whole-string regex scrub had been removed: it damaged legitimate content.

Only the delivered text changes. The persisted row and the messages returned to the model are untouched, so the model’s own context and cached prefix are unaffected — it still sees the memory next turn.

What is still uncovered

The PR lists its own gaps, and they are worth remembering. Surfaces that read the raw transcript still carry an echoed block: the messages in an API Run’s run.completed, and SessionDB.get_messages (the REST /api/sessions/{id}/messages endpoint, desktop history prefetch, API server session messages).

In other words: the delivery path is clean; some archive-reading paths are not. If you redistribute session transcripts — syncing them elsewhere, embedding them in another tool — that gap still applies to you.

What you should do

  • Update. The fix merged on 2026-11-12 (PR #153655). v0.23.1 shipped on 2026-11-10, so this is a main change, not a v0.23.1 one.
  • Keep credentials out of memory. Memory is data that gets injected into context every turn — by definition a high-exposure surface. Passwords, tokens and client PII belong in secrets or environment variables, not in MEMORY.md or a memory service. That advice held before this fix and holds after it.
  • Scope memory per profile. If a profile talks to outside recipients (email, group chats, support), its memory should not carry internal sensitive material. Isolating memory by profile beats cleaning up afterwards.
  • Audit your non-streaming channels. Email, webhooks and third-party API delivery all send final text straight out. Failures there produce no on-screen warning — only a message that has already left.

Update (2026-11-17): these changes shipped in v0.23.2 (November 16) — hermes update brings them in. The “not in v0.23.1” wording above is a snapshot from publication time.

Memory is what makes an agent feel like it knows your project. It is also a pile of things you assumed only you knew, riding along on every request. This channel is closed now; the habits are still yours to keep.

Related: the memory checkpoint gate, the memory command reference, and LanceDB semantic memory.