Flat MEMORY.md broke in 2 weeks: 30.9KB bloat evicted all coding rules; a 4-layer no-vector-DB fix
Adorable-Cost-3249 · reddit · 2026-11-20
After 12 days of logs (226 sessions, 1,337 turns), the author found their flat MEMORY.md had bloated startup injection to 30.9KB (7,700 tokens) per chat, while a naive "latest 8 facts" cap evicted 100% of architecture and UX invariants—coding subagents woke up with personal reminders instead of repo conventions.
Rebuilding local-first memory in the open-source agy-hq setup, they landed on five things that worked in a zero-database Markdown+JSONL stack:
- Role-aware startup budgets: main chat gets priorities plus a balanced topic slice (≤3 facts/topic); scoped coding subagents skip personal memory and load only their repo's playbook (≤1.2KB)
- No usage-based decay: perfect guardrails never lexically fire, so hit-counters auto-demote them; replaced with scope match + pinning + expiresat
- Dual-speed writes: human rules land in <5ms; agent-discovered lessons only update overnight via a 0-token stop hook and "dreaming" cross-checked against raw transcripts
- Curated Wiki + pure-Go BM25 (<15ms, no vector DB) with line-level citations; trade-off: misses zero-overlap synonyms
- Taint quarantine + cascading forget: sessions touching untrusted email lock memory read/write to block indirect prompt injection
The post also maps how Anthropic, OpenAI, xAI, Meta and Google converge and diverge on cross-session memory.
More from coding & agent
- In the agentic coding era, keeping a lab notebook may be the cure for offloaded thinking — rishabh16_ · 2026-11-21
- Agent-scale night: 21-person company hits $100M ARR with zero support teams — LukeW · 2026-11-21
- "Diagram Driven Development": make the AI-drawn logic diagram the single source of truth — max__drake · 2026-11-21
- shadcn launches UI SDK: reusable component behaviors designed for agent-built interfaces — shadcn · 2026-11-21
- Claude Code dual-model setup: one model plans and reviews, subagents write the code — PrajwalTomar_ · 2026-11-21
- Dev argues agent approval flows should let you approve actions by voice — NYCounihan · 2026-11-21