
The Three Layers
| Layer | Priority | Purpose | TTL |
|---|---|---|---|
| Rule | 10 (highest) | Persistent instructions and constraints | None |
| Working | 5 | Current session context, temporary notes | Optional |
| Long-term | 1 | General knowledge, facts, patterns | None |
Rule Layer
Rules are the highest priority memories. They represent instructions, constraints, and preferences that should always be active.get_context results.
Working Layer
Working memories represent temporary, session-relevant context. They support optional TTL viaexpiresAt.
get_context and listMemoriesByLayer.
Long-term Layer
Long-term memories store general knowledge accumulated over time.Context Budget Allocation
Whenget_context is called with a budget of N memories:
- Rule — Fetch all rules (up to N)
- Working — Fetch 60% of the remaining budget
- Long-term — Fill the rest
Scoring
When searching withsearch_memories, each memory receives a hybrid score:
| Component | Description |
|---|---|
| Semantic | Cosine similarity from vector search (0-1) |
| BM25 | Normalized full-text search rank (0-1) |
| Recency | Exponential decay from lastAccessedAt (half-life: 24h) |
| Salience | importance decayed over time |
weights parameter.