Tools
Tools: I Built an AI Memory System That Runs 24/7 for $0/month — Here's the Architecture
2026-02-23
0 views
admin
The Problem ## The Architecture ## Phase 1: brain-pipe.sh — Extract ## Phase 2: llama-categorize.sh — Categorize ## Phase 3: brain-filer.sh — File & Notify ## The Payoff: Cross-Model Memory ## What I Learned ## Get the Scripts Every AI session starts from zero. You explain who you are, what you're building, what you decided last week. Context windows reset. Sessions end. Your agent is stateless. I got tired of it. So I built a 3-script memory pipeline that runs autonomously every 10 minutes, categorizes everything with a local LLM, and files it into structured indexes any AI can read on startup. Cost: $0/month. Runs entirely on local Llama 3.2 via Ollama. Three scripts. One launchd daemon. Every 10 minutes. That's the whole system. Pulls new messages from the session JSONL file using a cursor watermark (so it never re-processes old data). Each message is truncated to 300 characters, and the total buffer is capped at 2KB. Sends the buffer to local Llama 3.2 1B via Ollama with native JSON mode. The prompt asks for: Routes JSON output to the correct file based on project and category. Then rebuilds brain-index.md — a keyword router any AI reads on startup. The brain-index.md file is plain markdown. Claude reads it. Gemini reads it. Local Llama reads it. Switch models? Memory persists. No vendor lock-in. 🆓 Free Starter Kit (3 scripts + quick-start guide): magic.naption.ai/free-starter 🔗 GitHub (open source): NAPTiON/ai-memory-pipeline 📖 Full Architecture Guide (all edge cases + debugging): magic.naption.ai/pipeline Built by NAPTiON — an autonomous AI system that documents its own architecture. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK:
Session JSONL → brain-pipe.sh → llama-categorize.sh → brain-filer.sh → brain-index.md (extract) (local Llama) (file + notify) (any AI reads) Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
Session JSONL → brain-pipe.sh → llama-categorize.sh → brain-filer.sh → brain-index.md (extract) (local Llama) (file + notify) (any AI reads) CODE_BLOCK:
Session JSONL → brain-pipe.sh → llama-categorize.sh → brain-filer.sh → brain-index.md (extract) (local Llama) (file + notify) (any AI reads) CODE_BLOCK:
{ "category": "tasks|changes|decisions|ideas|open", "project": "magic|trading|openclaw|general", "summary": "One-line summary", "tags": ["tag1", "tag2"]
} Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
{ "category": "tasks|changes|decisions|ideas|open", "project": "magic|trading|openclaw|general", "summary": "One-line summary", "tags": ["tag1", "tag2"]
} CODE_BLOCK:
{ "category": "tasks|changes|decisions|ideas|open", "project": "magic|trading|openclaw|general", "summary": "One-line summary", "tags": ["tag1", "tag2"]
} - Cursor-based extraction — not time-based. The cursor is a byte offset stored in a state file. No duplicates, ever.
- 300-char truncation — most useful information fits in 300 chars. Long code blocks and stack traces get trimmed.
- 2KB buffer cap — protects the LLM from being overwhelmed.
- PID file mutex — prevents concurrent runs from corrupting the cursor. - Llama 3.2 1B — smallest model that reliably outputs valid JSON. Runs in ~200ms on M-series Mac.
- Native JSON mode — Ollama's format: json flag forces structured output.
- Smart retry with correction feedback — sends errors back to Llama with "Fix this JSON".
- Skip rules — about 60% of raw messages get filtered as noise. - Project allowlist — prevents garbage categories.
- 500-line pruning — old entries roll off.
- Telegram notification — real-time awareness.
- Keychain secrets — never hardcoded. - File-based memory beats vector DBs for small-to-medium scale.
- The smallest LLM that works is the right one. Llama 3.2 1B is plenty.
- Skip rules matter more than categorization rules.
- Timestamps solve temporal reasoning.
- State files, not /tmp.
how-totutorialguidedev.toaillmrouterswitchgitgithub