Persistent Memory for Agno (formerly Phidata) Agents

Free · Open source (MIT) · Works with LangChain, CrewAI, AutoGen · No signup

Your Agno (formerly Phidata) agents lose their memory every time they restart. Conversations, learned preferences, and accumulated context vanish when the process dies. This breaks multi-session workflows and forces users to repeat themselves. BotWire Memory solves this with persistent key-value storage that survives restarts, process crashes, and machine reboots.

The Problem: Agent Memory Dies with the Process

Agno agents store state in Python variables and objects that exist only in RAM. When your agent process terminates—whether from a crash, deployment, or simple restart—all accumulated memory disappears.

Here's what breaks:

The core issue is that phidata memory exists only in the current Python process. Standard solutions like pickle files or JSON dumps are fragile, don't handle concurrency, and break in distributed environments. You need persistent agent memory that works across processes and machines.

The Fix: Persistent Memory in 3 Lines

Install BotWire Memory and replace in-memory storage with persistent key-value operations:

pip install botwire
from botwire import Memory

# Create persistent memory namespace
memory = Memory("agent-session-123")

# Store and retrieve across restarts  
memory.set("user_name", "Sarah")
memory.set("preferred_model", "gpt-4")

# Works after process restart
name = memory.get("user_name")  # "Sarah"
model = memory.get("preferred_model", "gpt-3.5-turbo")  # fallback default

This creates persistent agno memory that survives process restarts, deployments, and crashes.

How Persistent Memory Works

BotWire Memory operates as a persistent key-value store with HTTP backend. Each namespace acts as an isolated memory space for your agents.

Basic Operations

from botwire import Memory

# Namespace isolates different agents/users
user_memory = Memory("user-42")
agent_memory = Memory("assistant-v2")

# Store any JSON-serializable data
user_memory.set("conversation_history", [
    {"role": "user", "content": "What's the weather?"},
    {"role": "assistant", "content": "I'll check that for you."}
])

# Retrieve with defaults
history = user_memory.get("conversation_history", [])
last_topic = user_memory.get("last_topic", "general")

# List all keys in namespace
all_keys = user_memory.list_keys()
print(f"Stored keys: {all_keys}")

# Delete specific memories
user_memory.delete("temporary_data")

Real-World Patterns

The most common pattern is user-scoped persistent memory. Create one namespace per user session:

class PersistentAgent:
    def __init__(self, user_id):
        self.memory = Memory(f"user-{user_id}")
        self.user_id = user_id
    
    def remember_preference(self, key, value):
        preferences = self.memory.get("preferences", {})
        preferences[key] = value
        self.memory.set("preferences", preferences)
    
    def get_context(self):
        return {
            "preferences": self.memory.get("preferences", {}),
            "history": self.memory.get("conversation_history", []),
            "session_count": self.memory.get("session_count", 0)
        }
    
    def increment_session(self):
        count = self.memory.get("session_count", 0)
        self.memory.set("session_count", count + 1)

Memory persists across different processes and machines. Multiple agent instances can share the same namespace for coordinated memory.

Integration with Agno Agents

Integrate persistent memory directly into your Agno agent workflows:

from phi.agent import Agent
from botwire import Memory

class PersistentAgnoAgent:
    def __init__(self, user_id, model="gpt-4"):
        self.user_id = user_id
        self.memory = Memory(f"agno-user-{user_id}")
        
        # Initialize agent with persistent context
        self.agent = Agent(
            model=model,
            system_prompt=self._build_system_prompt()
        )
    
    def _build_system_prompt(self):
        context = self.memory.get("user_context", {})
        base_prompt = "You are a helpful assistant."
        
        if context:
            base_prompt += f"\n\nUser context: {context}"
            
        return base_prompt
    
    def chat(self, message):
        # Get conversation history
        history = self.memory.get("conversation_history", [])
        
        # Add user message
        history.append({"role": "user", "content": message})
        
        # Get response from agent
        response = self.agent.run(message)
        
        # Store response
        history.append({"role": "assistant", "content": response.content})
        self.memory.set("conversation_history", history[-20:])  # Keep last 20 messages
        
        return response
    
    def learn_preference(self, key, value):
        context = self.memory.get("user_context", {})
        context[key] = value
        self.memory.set("user_context", context)

This pattern maintains phidata state across agent restarts while preserving conversation flow and learned preferences.

When NOT to Use BotWire

BotWire Memory isn't the right solution for:

FAQ

Q: Why not just use Redis or a database? A: BotWire requires zero setup—no servers, no configuration, no connection strings. It's designed specifically for agent memory patterns with built-in namespacing and JSON serialization.

Q: Is this actually free? A: Yes, 1000 writes per day per namespace, forever. 50MB storage per namespace. Unlimited reads. No signup required, no API keys, no credit card.

Q: What about data privacy? A: Data is stored on BotWire servers. For sensitive applications, self-host the open source version (MIT license) using the FastAPI + SQLite service at github.com/pmestre-Forge/signal-api.

---

Stop losing agent memory on every restart. Install BotWire Memory and build persistent agno agents that remember across sessions: pip install botwire. Get started at botwire.dev.

Install in one command:

pip install botwire

Start free at botwire.dev