VikingBot: Build AI Agents with Persistent Context Using OpenViking
I spent weeks building AI agents from scratch. Each time I hit the same wall: memory management. My agents would forget user preferences, lose conversation context, and require me to rebuild the same infrastructure repeatedly.
Then I found VikingBot.
The Problem with Building Agents from Scratch
Every agent I built needed the same components:
- A way to store and retrieve memories
- Session management across conversations
- Platform adapters for different messaging apps
- A skill system for extensibility
I kept rewriting these pieces. Each new project meant setting up databases, designing memory schemas, building Telegram/Slack integrations. It was tedious and error-prone.
What I wanted was a framework that handled all this infrastructure so I could focus on the agent’s actual behavior.
Finding VikingBot
VikingBot sits on top of OpenViking, which provides a context database designed for AI applications. The key insight: it treats memory as a first-class citizen, not an afterthought.
I tried it:
pip install "openviking[bot]"That gave me the core agent framework. Then I started the server:
openviking-server --with-botAnd tested the CLI:
ov chatIt worked. But the real test was whether it would remember things.
Testing Persistent Memory
I started a conversation through the CLI:
Me: My name is Bob and I prefer Python over JavaScript.Bot: Got it, Bob! I'll remember you prefer Python.
Me: What programming language do I prefer?Bot: You prefer Python, Bob.I ended the session and started a new one:
Me: What's my name and what language do I prefer?Bot: Your name is Bob, and you prefer Python over JavaScript.The memory persisted across sessions. This was exactly what I needed.
Under the hood, OpenViking extracts memories from conversations and stores them in a structured format:
viking://user/memories/├── profile.md├── preferences/│ └── programming-languages.md└── entities/ └── bob.mdBuilding a Support Bot
I wanted to build a customer support bot that could remember user issues. Here’s what I came up with:
from vikingbot import Bot, Skill
bot = Bot()
# Add skillsbot.add_skill("search_docs")bot.add_skill("create_ticket")bot.add_skill("escalate")
# Platform integrationsbot.connect_telegram(token="...")bot.connect_slack(app_token="...")
# Startbot.run()The skill system uses markdown files for definitions:
# Search Documentation
Search through the knowledge base for relevant articles.
## Usage
Provide a query and the skill will return matching documentation.
## Examples
User: "How do I reset my password?"Skill searches docs and returns relevant articles.This declarative approach made it easy to add new capabilities without modifying core logic.
Multi-Platform Support
One of my requirements was deploying the same agent across multiple platforms. VikingBot handles this through optional dependencies:
# Telegram supportpip install "openviking[bot,bot-telegram]"
# Slack supportpip install "openviking[bot,bot-slack]"
# Feishu (for Chinese users)pip install "openviking[bot,bot-feishu]"
# Everythingpip install "openviking[bot-full]"I tested this with Telegram:
export TELEGRAM_BOT_TOKEN="your-token-here"openviking-server --with-botThe same agent logic that worked in the CLI now responded to Telegram messages. No code changes required.
Session Management
The session management is where VikingBot shines. I looked at how it handles conversations:
# Sessions automatically trackedsession = client.session("user_123")session.add_message("user", [TextPart("I need help with billing")])session.add_message("assistant", [TextPart("I'll help you with that")])session.commit() # Triggers memory extractionWhen commit() is called, the system:
- Analyzes the conversation
- Extracts relevant memories
- Stores them in the context database
- Makes them available for future sessions
This automatic memory extraction meant I didn’t have to write custom logic for each type of information I wanted to remember.
Directory Structure
I explored how the framework organizes data:
viking://agent/skills/├── search_web/│ ├── SKILL.md # Skill definition│ └── scripts/ # Optional scripts├── analyze_code/└── ...
viking://agent/memories/├── cases/ # Learned cases└── patterns/ # Learned patterns
viking://user/memories/├── profile.md├── preferences/└── entities/The viking:// protocol is OpenViking’s way of providing a virtual filesystem for agent data. It abstracts away whether data is stored locally, in PostgreSQL, or elsewhere.
Integration with OpenViking Server
VikingBot runs as part of the OpenViking server:
openviking-server --with-botThis gives you:
- HTTP API for programmatic access
- MCP server for Claude/Cursor integration
- Bot endpoints for messaging platforms
- Unified context storage
I could access the agent through:
- The CLI (
ov chat) - HTTP API (for custom integrations)
- Messaging platforms (Telegram, Slack, etc.)
- MCP (for IDE integration)
All backed by the same persistent memory.
What I Built
With VikingBot, I built a research assistant that:
- Remembers my research interests
- Tracks papers I’ve read
- Reminds me of connections between topics
- Works across Telegram and CLI
The memory system meant I could ask “What did I think about that Transformer optimization paper?” and it would recall our previous discussion.
Trade-offs
VikingBot isn’t perfect:
- The skill system requires learning a specific format
- Memory extraction can be slow for long conversations
- Platform-specific features (like Telegram keyboards) require custom handling
- Documentation is still evolving
But for my use case—building agents that need to remember things—it solved the core problem.
Installation Options
For development, I installed from source:
git clone https://github.com/bswen/openviking.gitcd openvikinguv pip install -e ".[bot]"For production, PyPI works fine:
pip install "openviking[bot]"Configuration
The bot uses pydantic-settings for configuration, which means environment variables:
# OpenAI (or compatible API)OPENAI_API_KEY=sk-...
# Database (PostgreSQL for production)DATABASE_URL=postgresql://user:pass@localhost/openviking
# Platform tokensTELEGRAM_BOT_TOKEN=...SLACK_APP_TOKEN=...I appreciated that it follows the twelve-factor app pattern.
In this post, I shared my experience using VikingBot to build AI agents with persistent memory. The framework sits on top of OpenViking and handles the infrastructure pieces I kept rebuilding: memory management, session tracking, and platform integrations. The result is agents that actually remember user preferences and conversation history across sessions.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments