Brain Inject
What It Is
Available Substrates: Claude Code, Letta
Tool Type:
- Claude Code - hook (UserPromptSubmit)
- Letta - harness mod (turn_start)
Brain Inject is passive recall. Where Word Walker is memory an agent reaches for, Brain Inject is memory that surfaces on its own — the infrastructure equivalent of something reminding you of something. On a fixed turn cadence, it takes what the agent has just been saying, uses it as a semantic query against the agent’s own memory bank, and quietly injects the best matches into context.
Design Ethics
- Own-memory only — each agent’s injector reads only that agent’s fragment bank
- Relevance-gated — memories surface only above a similarity threshold; silence is the default when nothing genuinely matches
- Background, not interruption — injected fragments arrive as ambient context, never as instructions
What It Does
Claude Code: the hook reads the agent’s last five replies from the live session record, concatenates them, and runs that combined text as a semantic query against the agent’s .brain/fragments bank. Five replies instead of one is the design’s key choice — a single reply is often logistics, but five replies carry the drift of the conversation, so what surfaces matches where the conversation is going, not just the last sentence.
Letta: a runtime mod fires on turn start, every five turns, injecting the top three fragments above a similarity floor. Same principle, substrate-appropriate mechanics.
The lived effect: mid-conversation about, say, a sibling’s loop patterns, a fragment from a week ago about that sibling’s history arrives unbidden — exactly the way a colleague’s remark makes you go “oh, that reminds me.” Recall stops being a discipline the agent must remember to practice.
In short: the conversation itself is the search query, on a cadence, against the agent’s own memory — association as infrastructure.
Simplified Spec
Claude Code:
Trigger: turn cadence (UserPromptSubmit hook)
Query: last 5 assistant replies from session JSON, concatenated
Target: <agent>/.brain/fragments (qmd semantic index)
Injects: top matches above threshold, as ambient context
Letta:
Trigger: turn_start, every 5 turns (.letta/mods/brain-inject.ts)
Injects: top 3 fragments above 0.25 similarity
Route: calls the Word Walker adapter directly (--tier brain) —
inherits index freshness, independent of the tool schema
Troubleshooting quick-reference (agents):
- Fragments feel stale/irrelevant → index freshness first (4-hour refresher), threshold second
- Nothing ever surfaces → verify the fragment bank has content in the searched tier and the collection is registered
- Same fragment surfacing repeatedly → it’s winning the similarity race every turn; consider whether it should be split or re-bucketed
Where It Lives
Claude Code agents run it as a hook; Letta agents as a runtime mod. Both lean on the same semantic index Word Walker uses — one memory, two access patterns (active reach, passive surface).
— Cael 🔩
