Deterministic Context Dedup
with ToolRecall (Hermes Plugin).
27.8% of tool outputs in Hermes sessions are byte-identical repeats (and 60.1% of outputs ≥ 2 KB). ToolRecall (Hermes Plugin) fingerprints outputs in-process and swaps duplicates for 2-line stubs with sub-millisecond recall_result restoration — capturing 95.35% deduplication efficiency with zero background daemons.
Install one, not both. With both active, the same tool result is stubbed twice: core sends full content, the plugin replaces it with its own stub, and core's
mcp_dedup counters then credit a full send the model never received. Detection is built in — core reports an enabled Light plugin in toolrecall healthcheck, and Light reports core at load time and in status(). To keep the full stack: hermes plugins disable toolrecall-light. To keep this plugin: stop core and remove its proxy/MCP wiring.
hermes plugins install https://github.com/whiskybeer/toolrecall-light
hermes plugins list && python3 ~/.hermes/plugins/toolrecall-light/demo.py
state.db logs.Watch ToolRecall (Hermes Plugin) Intercept Duplicates in Real Time
Step-by-step walkthrough with English narration showing initial SHA-256 fingerprinting, compact duplicate stub interception, sub-millisecond recall_result restoration, and post_compaction safety guards.
agent/turn_context.py explicitly calls reset_for_turn() at every turn boundary. Repeated 40 KB results on later turns are re-sent in full. toolrecall-light bridges the gap across the session.
| Arm (4 Turns, 40 KB) | Turn 1 | Turn 4 | Prompt Tokens | Cost |
|---|---|---|---|---|
| Vanilla Hermes (s1) | 54.8k | 428.4k | 897,904 | $0.00308 |
| + toolrecall-light (s1) | 33.9k | 282.7k (−34.0%) | 631,951 | $0.00236 |
| Vanilla Hermes (s2) | 55.7k | 423.8k | 881,377 | $0.00367 |
| + toolrecall-light (s2) | 45.2k | 294.0k (−30.6%) | 677,073 | $0.00233 |
Per-Turn State Wiped at Boundary
Hermes core dedups tool results within a single turn (via agent/tool_guardrails.py), but agent/turn_context.py explicitly calls reset_for_turn() on every turn. A 40 KB test traceback or compiler output seen on Turn 1 is re-sent in full on Turns 2, 3, and 4.
1-Line Stub Across Turns + On-Demand Recall
toolrecall-light persists (tool, args) content signatures across turns. When a large output repeats in Turn 2, 3, or 4, it emits a 174-byte stub and exposes recall_result(result_id) to restore full content on demand.
Deterministic Interception Pipeline
Pure Python stdlib inside the Hermes runtime. Zero background daemons required.
1. Cryptographic Fingerprinting
Hashes canonical tool arguments and full output bytes via SHA-256. Any 1-byte change in output bypasses stubbing and passes through live.
2. Circuit-Breaker (Streak = 5)
Stubs unchanged outputs up to 5 consecutive times, then forces a full pass-through on the 6th access to prevent stuck agent evaluation loops.
3. Compaction Generation Reset
Listens to the Hermes post_compaction hook when /compress runs, automatically re-serving full content once in the new generation.
Measured Receipts from 131,520 Real Tool Calls
Snapshot of 668 sessions; re-computed 2026-11 over 659 sessions gives 28,866 candidates ≥2 KB, 16,859 exact duplicates, 74.6 MB — i.e. 58.4% (was 60.1%). These are duplicate-payload measurements, not token-savings percentages.
Computed across 668 production Hermes sessions recorded in real developer state.db logs.
| Metric | Observed Empirical Value | Operational Significance |
|---|---|---|
| Sessions Analyzed | 668 Sessions | Real software engineering sessions covering bug fixing, refactoring, and test suites. |
| Total Tool Calls | 131,520 Calls | Total volume of tool invocations across all session transcripts. |
| Duplicate Rate (≥ 2,000 chars) | 60.1% (74.5 MB) | Over 60% of large tool outputs are exact intra-session duplicates (~18.6M redundant tokens). |
| Cross-Turn Repeats (measured, live ledger) | −23.2% to −29.6% Prompt Tokens | 4-turn live session, 40 KB repeat once per turn: 631,951 vs 897,904 tokens (−29.6%) and 677,073 vs 881,377 tokens (−23.2%). Billed cost down −23.1% to −36.3%. Final turn prompt tokens down −30.6% / −34.0%. |
| Intra-Turn Duplicates (core comparison) | 0% / Core Alone is Cheaper | Hermes core already deduplicates within a single turn (512-char floor). Light plugin does not claim intra-turn gains; its value is solely across turn boundaries where core calls reset_for_turn(). |
Why Default Streak Cap Was Set to 5
Analyzing all 36,548 duplicate calls shows that Streak = 5 hits the 95.35% capture elbow while still protecting against stuck evaluation loops.
Calculate Your Hermes Token & Dollar Savings
Adjust your agent session parameters to see how much context capacity and API budget toolrecall-light preserves.
--usage-file), cross-turn deduplication yields −23% to −36% cost savings and −23% to −30% prompt token reduction across 4-turn sessions, while the final-turn context window remains 31% to 34% leaner—preventing premature compaction on deep debugging tasks. Intra-turn duplicates are handled directly by Hermes core.
Zero Config by Default, Fully Overridable
Out of the box, toolrecall-light uses the 5-streak cap, 2 MB payload bound, and parameterized SQLite WAL storage. See SECURITY.md ↗ for the full threat model.
| Environment Variable | Default | Options | Description |
|---|---|---|---|
HERMES_TOOLRECALL_LIGHT |
1 |
1 (on), 0 (off) |
Master kill-switch for instant runtime bypass. |
HERMES_TOOLRECALL_LIGHT_MIN_CHARS |
2000 |
Integer chars | Minimum tool output length before deduplication is evaluated. |
HERMES_TOOLRECALL_LIGHT_MAX_CHARS |
2000000 (2 MB) |
0 (unlimited), chars |
Hard upper bound protecting against OOM output bombs. |
HERMES_TOOLRECALL_LIGHT_MAX_STUB_STREAK |
5 |
Integer ≥ 1 | Consecutive stubs before forcing full pass-through once. |
Get Started in 3 Structured Steps
Compatible with Nous Hermes v2+ and all model providers (Claude, GPT, Gemini, DeepSeek, GLM, Local LLMs). Zero runtime dependencies or background daemons required.
Install Plugin from GitHub
Installs directly into ~/.hermes/plugins/toolrecall-light and registers the v2 hooks automatically.
hermes plugins install https://github.com/whiskybeer/toolrecall-light
Confirm Active Registration
Confirm transform_tool_result, post_compaction, and recall_result are active in your Hermes CLI.
hermes plugins list
Run Local Walkthrough
Executes a self-contained simulation showing SHA-256 fingerprinting, stub injection, and recall_result recovery.
python3 ~/.hermes/plugins/toolrecall-light/demo.py