| name | hermes-streaming-scrubber |
| description | Scrub <memory-context> tags from LLM streaming output before displaying to UI — prevents internal memory blocks leaking into user-visible text. Stateful across chunk boundaries. Source: NousResearch/hermes-agent (MIT). |
Implementation (real, runnable — added 2026-06-19)
StreamingContextScrubber was already pure and self-contained in the
original — ported close to verbatim, no hermes-specific dependencies to
strip.
- Module:
core/lib/hermes_adapted/context_scrubber.py (StreamingContextScrubber,
split out from memory_manager.py to make room for its lifecycle hooks)
- Tests:
tests/test_hermes_context_scrubber.py (5 passing, incl. 2 for this class)
/hermes-streaming-scrubber
When to Use
- Agent uses memory injection via
<memory-context> blocks in the system/assistant stream
- Streaming response passes through a proxy before reaching the UI (Yana AI, chat frontend)
- Need to prevent raw memory dumps appearing as assistant text to the user
- Any LLM pipeline where internal context markers must not be visible downstream
Do NOT use for
- Non-streaming (full response) pipelines — strip with regex post-call instead
- Removing user-visible content (only strip fenced internal markers)
- See also: [[hermes-memory-manager]] for the full memory architecture
The Problem
When an agent injects memory via a <memory-context>...</memory-context> fence and
streams the response, chunks can split across the tag boundary:
chunk 1: "Here is what I found. <memory-cont"
chunk 2: "ext>\n[recalled: user prefers Python]\n</memory-context>\nI recommend..."
A naïve string-replace misses split tags. The result: raw memory leaks to the user's UI.