← Back to honi.dev

Memory

Honi provides four tiers of memory, each backed by a different Cloudflare primitive. Use one, two, or all four depending on your agent's needs.

Overview

TierBackingPersistenceUse Case
WorkingDurable ObjectSession-scopedConversation history, scratch state
EpisodicD1 (SQLite)PermanentPast conversations, user facts, long-term context
SemanticVectorize + Workers AIPermanentSimilarity search over knowledge, RAG
Graphedgraph (Durable Object)PermanentEntity relationships, knowledge graphs, structural recall

Working Memory (Durable Object)

Working memory is always enabled — no configuration needed. It stores the current conversation messages in the Durable Object's transactional storage.

TypeScript
1// Working memory is automatic — just create an agent
2export const agent = createAgent({
3 name: 'my-agent',
4 model: 'claude-sonnet-4-20250514'
5})

Each session gets its own isolated working memory within the Durable Object. Messages are persisted across requests within a session and cleared on DELETE /chat.

Episodic Memory (D1)

Episodic memory stores structured facts and past conversation summaries in a D1 database. This allows agents to recall information from previous sessions.

TypeScript
1export const agent = createAgent({
2 name: 'my-agent',
3 model: 'claude-sonnet-4-20250514',
4 memory: {
5 episodic: { binding: 'MEMORY_DB' }
6 }
7})

Semantic Memory (Vectorize + AI)

Semantic memory enables similarity-based retrieval over a knowledge base. Honi uses Cloudflare Vectorize for vector storage and Workers AI for embedding generation.

TypeScript
1export const agent = createAgent({
2 name: 'my-agent',
3 model: 'claude-sonnet-4-20250514',
4 memory: {
5 episodic: { binding: 'MEMORY_DB' },
6 semantic: { vectorize: 'VECTORIZE', ai: 'AI' }
7 }
8})

Or use the shorthand 'tiered' to enable all three tiers with default bindings:

TypeScript
1memory: 'tiered' // equivalent to all three tiers with default bindings

Full wrangler.toml

Here's a complete wrangler.toml with all three memory tiers configured:

TOML
1name = "my-agent"
2main = "src/index.ts"
3compatibility_date = "2024-12-01"
4
5# Working memory — Durable Object
6[[durable_objects.bindings]]
7name = "AGENT"
8class_name = "AgentDO"
9
10[[migrations]]
11tag = "v1"
12new_classes = ["AgentDO"]
13
14# Episodic memory — D1
15[[d1_databases]]
16binding = "MEMORY_DB"
17database_name = "agent-memory"
18database_id = "your-database-id"
19
20# Semantic memory — Vectorize + Workers AI
21[[vectorize]]
22binding = "VECTORIZE"
23index_name = "agent-knowledge"
24
25[ai]
26binding = "AI"