Working Memory

The agent's immediate context — recent observations, active conversations, and current tool results. Fastest access, limited capacity, and subject to eviction.

Schema

ColumnTypeDescription
idTEXTUUIDv4 primary key
contentTEXTRaw memory content
sourceTEXTOrigin (user, tool, observation)
timestampTEXTApplication-level timestamp
session_idTEXTSession grouping key (default: 'default')
importanceREAL0.0–1.0 importance score (default: 0.5)
metadata_jsonTEXTArbitrary JSON metadata blob
created_atTIMESTAMPRow creation time (SQLite CURRENT_TIMESTAMP)
recall_countINTEGERNumber of times recalled (default: 0)
last_recalledTIMESTAMPLast recall time (default: NULL)
valid_untilTIMESTAMPTTL expiry time
superseded_byTEXTID of newer version that replaces this entry
scopeTEXTVisibility scope (default: 'global')

Indexes

  • idx_working_session on session_id
  • idx_working_timestamp on timestamp
  • idx_working_source on source

FTS5

Full-text search is maintained via fts_working (content-column FTS5) with automatic triggers for INSERT, UPDATE, and DELETE.

Embeddings are stored separately in vec_episodes (sqlite-vec, int8[384]). They are generated at recall time and are not a column in the working_memory table.

Eviction Policy

When Working Memory reaches capacity, entries are evicted by a composite score:

  1. Importance weighting: Higher importance = lower eviction priority
  2. Recency: Recently created or recalled entries are protected
  3. Recall frequency: Entries with higher recall_count are protected
  4. Composite score: score = importance * recency_factor * recall_factor

Consolidation Path


flowchart LR
  A[New Entry] -->|insert| WM[Working Memory]
  WM -->|TTL/2 age trigger| C{Consolidation}
  C -->|group by source| S[Summarize via LLM/AAAK]
  S -->|promote| EM[Episodic Memory]
  C -->|evict originals| DEL[Evicted]

API Reference

# Store a memory
mem.remember(content, importance=0.5, source="user")

# Recall memories (FTS5 + vector hybrid)
results = mem.recall(query, top_k=10)

# Update a memory
mem.update(id, content=None, importance=None)

# Delete a single memory
mem.forget(id)

Performance

MetricValue
Median write15ms
Median read8ms
Median recall45ms
Max capacity10,000 entries (configurable via MNEMOSYNE_WM_MAX)
Memory footprint~50MB per 1K entries
Tip

Use high importance (0.8+) for critical facts you want promoted to Episodic Memory. Use low importance (0.2-) for transient observations that should be evicted quickly.