OpenViking: Contextual Database to Improve Prompt Memory in AI Agents
Machine-translated from Italian. Read the original
What is OpenViking
OpenViking is a contextual database designed for autonomous agents based on LLMs. (DONE) It allows storing, indexing, and retrieving conversation fragments or results of previous actions via vector embeddings, in order to dynamically enrich an agent's system prompt. (DONE) The project was presented by HTML.it as an evolution of the classic RAG (Retrieval‑Augmented Generation) approach. (DONE)
How the Context Archive Works
- Ingestion – Every exchange (prompt, response, tool result) is transformed into an embedding (e.g., OpenAI
text-embedding-3-large). - Indexing – Embeddings are saved in an internal vector index within OpenViking, associated with metadata (timestamp, agent ID, tags). (DONE)
- Query – When the agent needs to “remember” something, it sends a textual query; the database returns the chunks most similar to the current context, with similarity scores.
- Prompt Integration – The returned chunks are inserted into the system prompt (or a separate memory prompt) before generating the response.
Advantages Over Traditional RAG
| Feature | Traditional RAG | OpenViking |
|---|---|---|
| Content Type | Static documents (PDF, wiki) | Conversations, tool results, operational state |
| State Persistence | No explicit management; context limited to a few thousand tokens | Long-term memory with configurable TTL, chunk versioning |
| Multi‑Agent Coordination | Requires external mechanisms | Native support for agent ID and shared memory |
| Scalability | Offline indexing, slow updates | Real-time updates, O(1) insertion |
Practical Integration Example (Node.js)
import OpenViking from 'openviking-sdk';
const vik = new OpenViking({apiKey: process.env.VIKING_KEY});
// 1. Saving an interaction
async function storeInteraction(agentId, userMsg, assistantMsg) {
await vik.upsert({
agentId,
content: `${userMsg}\n${assistantMsg}`,
metadata: {tags: ['chat']}
});
}
// 2. Retrieving context before generating a response
async function enrichPrompt(agentId, currentUserMsg) {
const similar = await vik.search({
agentId,
query: currentUserMsg,
topK: 3
});
const memory = similar.map(r => r.content).join('\n---\n');
return `Memory:\n${memory}\n\nUser: ${currentUserMsg}`;
}
Note: the code is indicative; the exact API signatures are to be confirmed in the official OpenViking documentation. (DON'T KNOW)
Operational Considerations
- Security: stored data is encrypted at rest; it is advisable to define retention policies to avoid indefinite retention of sensitive information. (DONE)
- Costs: the pricing model is not public; it is necessary to consult the OpenViking site for plans and limits. (DON'T KNOW)
- Performance: search latency depends on the number of indexed chunks; for scenarios with thousands of interactions, it is advisable to monitor response times and, if necessary, partition by agent.
Questions for the Community
- What patterns have you adopted to manage chunk expiration (TTL) in OpenViking or similar solutions?
- Have you encountered consistency issues when multiple agents share the same context space? How did you resolve them?
- What metrics do you monitor (e.g., search time, hit‑rate) to evaluate the effectiveness of the contextual database in your LLM pipeline?