An AI SDK agent whose entire long-term memory is one
Markdown file, MEMORY.md. The agent reads it, greps it, and writes to it with
ordinary file-style tools. The "file" is virtual and lives in
Upstash Redis.
Memory model inspired by https://docs.openclaw.ai/concepts/memory.
┌──────────────┐ tools ┌──────────────┐ string key ┌─────────────┐
│ Claude │ ──────────▶ │ lib/memory.ts│ ─────────────▶ │ Upstash │
│ (AI SDK) │ read/grep │ read/write │ memory:MEMORY │ Redis │
│ │ write/edit │ edit/grep │ memory:oplog │ │
└──────────────┘ └──────────────┘ └─────────────┘
-
Add your Anthropic key and Upstash Redis credentials to
.env:UPSTASH_REDIS_REST_URL= UPSTASH_REDIS_REST_TOKEN= ANTHROPIC_API_KEY=sk-ant-... -
Start it:
bun dev
Open http://localhost:3000.
-
Tell the agent something about yourself ("I'm Josh, I prefer TypeScript") and watch it write to
MEMORY.mdon the right. Ask "what do you remember?" in a fresh message and it reads the file back. Reset demo wipes it between takes.