Layer 5: Context Manager <- Manages the LLM's context window
| Monitors token usage (tiktoken for OpenAI, 3.5 chars/token Anthropic,
| 4 chars/token fallback)
| Proactive flush facts at 60% capacity
| Auto-compact summarize at 70% capacity
| Warning at 80% capacity
| Extracts facts before discarding messages
|
Layer 4: Learnings <- Self-improvement through failure tracking
| learnings/errors.md (tool failures with context)
| learnings/corrections.md (user corrections and preferences)
| Auto-injected into system prompt each session
|
Layer 3: Workspace Files <- Durable, human-readable storage
| SOUL.md (4K cap) (personality + behavioral instructions)
| INSTRUCTIONS.md (12K cap) (loaded into system prompt)
| USER.md (4K cap) (user preferences and context)
| MEMORY.md (16K cap) (curated long-term facts)
| INTERFACE.md (4K cap) (cross-agent interface contract)
| AGENTS.md (12K cap) (engine-root agent descriptions)
| HEARTBEAT.md (uncapped) (autonomous monitoring rules)
| PROJECT.md (read-only) (optional project context, bootstrap-only)
| SYSTEM.md (6K cap, read-only, auto-generated, 5-min refresh)
| memory/YYYY-MM-DD.md (daily session logs)
| Total bootstrap injection cap: 48K chars
| BM25 search (k1=1.5, b=0.75) across markdown files
|
Layer 2: Structured Memory DB <- Hybrid vector + keyword
| SQLite + sqlite-vec + FTS5
| Facts with embeddings — text-embedding-3-small (1536 dims)
| Auto-categorization with category-scoped search
| 3-tier retrieval: categories -> scoped facts -> flat fallback
| Hybrid scoring: (0.7 * vector + 0.3 * keyword) * decay_score
|
Layer 1: Salience Tracking <- Prioritizes important facts
SALIENCE_DECAY_RATE=0.95
Access-count boost capped at 10.0
High-salience facts auto-surface in initial context