Repository navigation
Description
Problem
Uteke auto-recall hook works correctly β it fires on agent:start, queries relevant memories, and writes results to /tmp/hermes/uteke-context/{agent}.md. However, agents frequently ignore the recalled context despite it being available.
Root Cause Analysis
-
Context file is passive β The hook writes to a file, but agents must explicitly
read_file()it. LLMs tend to skip reading context files unless strongly prompted. -
No injection into system prompt β Unlike
knowledgetool which hassearch_knowledgebaked into the SOUL.md instructions, uteke recall results are stored in a side-file that agents "should" read but often forget. -
Recall timing β The hook runs on
agent:startwhich is correct, but the context file gets overwritten each turn. If the agent doesn't read it in the first response, the opportunity is lost. -
Dual namespace confusion β Hook queries both
hermes-knowledgeand{agent}namespaces, but the agent's SOUL.md only mentions manualuteke recallβ no instruction to read the auto-generated context file. -
No feedback loop β Agents don't report whether they used recalled memories. No metric to measure recall utilization.
Proposal: Multi-layered Recall Optimization
Layer 1: Direct System Prompt Injection (High Impact, Low Effort)
Instead of writing to a file that agents must read, inject recalled memories directly into the message context via the hook system.
Implementation:
# In handler.py handle() function for agent:start
# Instead of (or in addition to) writing to file:
# Return the recalled context so gateway can inject it
def handle(event_type: str, context: dict):
if event_type == "agent:start":
# ... recall logic ...
# Option A: Return as hook result for gateway injection
return {
"inject_system": "\n".join(formatted_results),
"inject_section": "uteke-recall" # marker for dedup
}Gateway would prepend this to the user message or append to system prompt.
Layer 2: Hermes Plugin Integration (High Impact, Medium Effort)
Create a proper Hermes tool plugin that wraps uteke as a native tool:
# In agent config.yaml tools section
tools:
- name: uteke_recall
description: "Recall relevant memories from local uteke store"
command: "uteke recall"
auto_run: true # run automatically at session startThis makes uteke a first-class tool like knowledge β agents see it in their tool list and are prompted to use it.
Layer 3: Persistent Recall Summary in SOUL.md (Medium Impact, Low Effort)
Add a section to SOUL.md templates:
## Uteke Context (Auto-Loaded)
> The following memories were auto-recalled for this session.
> File: /tmp/hermes/uteke-context/{agent}.md
> β οΈ YOU MUST read this file before responding to any message.Layer 4: Recall Metrics and Dashboard (Low Impact, High Effort)
Track recall utilization:
recall_countβ how many times recall firedusage_countβ how many times agent referenced recalled contenthit_rateβ usage_count / recall_count
Expose via uteke stats --detailed or a dashboard.
Layer 5: Smart Recall Caching (Medium Impact, Medium Effort)
Currently recall runs on every agent:start event (every message). Optimize:
- Cache recall results keyed by message hash
- Only re-run if message topic changes significantly (>0.3 embedding distance)
- TTL cache: reuse results for follow-up messages in same topic
- Invalidate on topic shift detection
This reduces uteke CPU usage and prevents context file thrashing.
Recommended Priority
| Layer | Impact | Effort | Priority |
|---|---|---|---|
| Layer 1: System prompt injection | High | Low | P1 β Do first |
| Layer 3: SOUL.md instruction fix | High | Low | P1 β Do first |
| Layer 2: Hermes plugin tool | Medium | Medium | P2 |
| Layer 5: Smart caching | Medium | Medium | P2 |
| Layer 4: Metrics dashboard | Low | High | P3 |
Acceptance Criteria
- Agent reads recalled memories in >90% of sessions (measured by checking if recalled content appears in agent responses)
- Recall context is visible in agent's first response without manual file read
- No performance regression (recall + injection < 500ms total)
- Works for all Hermes agents (namespace-aware)
- Backward compatible β existing hook + file approach still works as fallback
Related
- feat: Hermes plugin for uteke integration (optional)Β #55 (Hermes plugin for uteke integration)
- π [P2] Complete Python wrapper to 100% command coverageΒ #137 (Python wrapper β could support injection API)
Activity
ajianaz commentedon Jun 11, 2026
π§ Update: Room as Natural Recall Trigger (from SurrealDB analysis, #286)
Room Solves the Recall Gap
The root problem identified in this issue β agents ignoring recalled context β has a natural solution via Rooms (#286):
How Room Fixes This
--roomflag β agent automatically has room contextuteke recall --room <id>β no passive file that agents must remember to readImplementation: Room-Aware Recall Hook
Updated Acceptance Criteria (add to existing)
--roomauto-set)Dependency Note
#286 (Room) must be implemented first β room tables and CLI must exist before hooks can use them. This issue (#181) becomes the integration layer between room feature and Hermes gateway. Order: #249 β #286 β #246 β #248 β #247 β THIS (#181).
fix(#181): address Cora review findings on recall cache
fix(#181): address all Cora review findings β cache key, strategy, foβ¦
feat(codecoradev#181): agent recall optimization with caching and conβ¦
feat(#181): agent recall optimization with caching and context output (β¦