Every session ends, every context window fills up, and then your agent forgets everything. I’ve been building out persistent memory for my OpenClaw setup using a sidecar service called OpenViking. Here’s what I learned: what works, what breaks silently, and where the tricky parts are.
The Problem Isn’t Storage — It’s Retrieval
The naive solution is a MEMORY.md that accumulates facts, preferences, and decisions. It works at first. Then it grows into a wall of text you paste into every prompt, burning tokens on information mostly irrelevant to the current task. You can grep it, but grep is keyword matching, not semantic understanding.
The other failure mode is maintenance. Keeping MEMORY.md fresh requires ongoing discipline — remember to update it, decide what’s worth keeping, prune stale information. In practice, it becomes a graveyard of outdated facts.
What you actually want: a memory system that persists across sessions without manual effort, surfaces relevant context automatically, and scales to thousands of facts without degrading.
Enter OpenViking: Local-First Semantic Memory
OpenViking is a locally-deployed semantic memory service that runs as a sidecar alongside OpenClaw. No cloud dependency, no data leaving your machine. You ingest resources (documents, notes, code), it builds semantic indexes, and you query them with natural language.
The OpenClaw integration is the memory-openviking plugin, which adds two automatic behaviors:
- autoRecall: before each agent turn, searches OpenViking for relevant memories and injects them into context
- autoCapture: after conversations, extracts and stores memories automatically
When it works, the agent surfaces relevant past decisions without being asked, remembers preferences, and connects the current task to prior work.
Architecture
Here’s how the pieces fit together — simplified to the parts that matter for understanding the data flow:
flowchart LR
subgraph OpenClaw
A[Agent Turn] --> B[memory-openviking plugin]
B -->|inject recalled context| A
end
subgraph OpenViking["OpenViking :1933"]
C[Semantic Index]
D[Session Store]
end
B -->|search query| C
B -->|session messages + commit| D
subgraph Workspace
G["Markdown Files\ndocs/, memory/"]
H[Code Repos]
end
G -->|nightly sync scripts| C
H -->|on-demand ingest| C
Read path: The plugin calls OpenViking’s search API, gets semantically relevant memories, and injects them into the prompt automatically.
Write path: Conversations flow into OpenViking sessions. At commit time, OpenViking extracts preferences, entities, and events and stores them in the viking:// namespace.
Resource ingestion: Static files (docs, code repos, task logs) get imported via sync scripts that run periodically. This is the knowledge base the agent searches.
Patterns That Actually Work
Project Knowledge Base via Resource Ingestion
I ingest my code repositories and planning docs into OpenViking. What surprised me is how useful this becomes over time — not just file contents, but reasoning embedded in design docs and planning notes. When working on a new feature, the agent can surface “we tried this approach in February and found it problematic for X reason” without me having to mention it.
The key is keeping the index fresh. A nightly sync script does this. Without it, you start getting stale or missing results and don’t immediately know why.
Automatic Conversation Distillation
This is the most compelling feature: you have a productive session, decisions get made, preferences get established — and OpenViking extracts those facts for future sessions. No manual effort.
The failure modes are real, and I’ll cover them below.
Layered Memory: Files for State, OV for Knowledge
This took me a while to internalize: OpenViking is not a replacement for structured file-based state.
My agent uses a task-board.json as the authoritative source of truth for task status. OpenViking is explicitly not used for this. Task state needs to be deterministic, auditable, and writable in a controlled way. Semantic search is good for knowledge retrieval, bad for “what is the current status of task OC-4?”
Files for structure and state. OpenViking for semantic knowledge and recall. The moment you start treating a vector store as a database, you’ll make decisions based on fuzzy matches instead of ground truth.
Incremental Sync for Workspace Files
Not everything lives in conversations. Operational files — task logs, planning docs, daily notes — accumulate value but never flow through the chat interface. A periodic sync script ingests these into OpenViking as resources.
Without this, chat history is indexed and everything else isn’t. That gap is larger than it sounds.
Pitfalls Worth Knowing
Silent Failures Are the Norm
The hardest thing about this class of system is that failures are invisible. If memory extraction breaks, nothing crashes. The agent just starts forgetting things. You might not notice for days.
Build explicit verification: a simple test that writes a known fact and queries for it. Don’t assume something is running because you set it up.
autoCapture Has Blind Spots
autoCapture can only extract what it observes in conversations. Information written directly to disk — daily logs, task boards updated by scripts — bypasses the conversation entirely and never enters the pipeline.
The fix is explicit sync scripts: periodically import important workspace files into OpenViking as resources. Extra step, but necessary.
Memory Pollution Compounds
Every memory extraction is a guess. OpenViking infers what’s worth remembering and sometimes guesses wrong — a tentative idea stored as a confirmed decision, an off-hand comment stored as a preference. Bad memories surface alongside good ones and subtly bias future responses.
Being intentional about when to commit sessions (not after every casual exchange) helps. So does occasionally auditing what’s actually stored.
Where This Is Going
I’m treating the current setup as an observation phase: watch what gets extracted, evaluate quality, then tune. The direction I find most interesting is usage-feedback-driven memory decay — memories that fade if never surfaced in recall, and strengthen if consistently relevant. A flat store that grows monotonically isn’t a good model for how useful knowledge actually works.
The Core Argument
Without persistent memory, every session starts from zero. You re-establish context, re-explain preferences, re-surface relevant history. The agent is capable but amnesiac, and you’re the one carrying all the continuity.
With a working memory system, sessions build on each other. The agent accumulates a working model of you, your projects, your preferences. OpenClaw + OpenViking is, in my experience, one of the most practical local-first approaches to this problem — not magic, but when running right, the difference is noticeable from the first session.
The tricky part is discipline: maintain the pipeline, audit the outputs, and resist using semantic search for things that need deterministic answers.
This post reflects practical experience building and maintaining an AI agent memory system. Architecture details are illustrative; specific implementation choices will vary with your setup.