Persistent Memory for CrewAI Agents (Cross-Session State)

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

Your CrewAI agents forget everything between kickoff() calls because CrewAI doesn't persist memory across sessions. Each time you restart your script, agents lose all context from previous runs. This breaks multi-session workflows where agents need to remember past decisions, learned information, or build on previous work. Here's how to add persistent memory that survives restarts.

The Problem: CrewAI Memory Vanishes

CrewAI agents live entirely in RAM. When your process ends, everything dies with it. This creates painful scenarios:

from crewai import Crew, Agent, Task

# This agent forgets everything after the script ends
researcher = Agent(
    role="Research Analyst",
    goal="Research competitors",
    backstory="Expert at market analysis"
)

crew = Crew(agents=[researcher], tasks=[...])
result1 = crew.kickoff()  # Agent learns something valuable
# Script ends, process restarts
result2 = crew.kickoff()  # Agent has amnesia — starts from zero

Without persistent state, your agents waste time and provide inconsistent experiences across sessions.

The Fix: Add Persistent Memory

Install BotWire to give your CrewAI agents memory that survives between runs:

pip install botwire
from crewai import Crew, Agent, Task
from botwire.memory import memory_tools

# Create persistent memory tools for your crew
tools = memory_tools("my-crew-research")

researcher = Agent(
    role="Research Analyst", 
    goal="Research competitors and remember findings",
    backstory="Expert at market analysis with perfect memory",
    tools=tools  # Now the agent can remember/recall across sessions
)

task = Task(
    description="""Research TechCorp's pricing. 
    First check if you already researched this before.
    Store any new findings for future reference.""",
    agent=researcher
)

crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()

Your agent now has remember, recall, and list_memory tools that persist across restarts.

How It Works

The memory_tools() function returns three CrewAI-compatible tools:

These tools hit BotWire's API to persist data beyond your process lifecycle. The agent automatically uses them during reasoning:

from botwire.memory import memory_tools
from crewai import Agent, Task, Crew

# Each namespace is isolated — use different ones for different crews
sales_tools = memory_tools("sales-crew")  
research_tools = memory_tools("research-crew")

sales_agent = Agent(
    role="Sales Analyst",
    goal="Track customer interactions over time",
    backstory="Relationship builder who never forgets a detail",
    tools=sales_tools
)

# Agent will naturally use memory tools in its reasoning
task = Task(
    description="Check our conversation history with Acme Corp, then plan next steps",
    agent=sales_agent
)

crew = Crew(agents=[sales_agent], tasks=[task])
result = crew.kickoff()

# Later (different process, different day):
# The agent remembers everything about Acme Corp

You can also interact with memory directly in your orchestration code:

from botwire import Memory

# Same namespace as your agents — shared memory space
memory = Memory("sales-crew")

# Pre-populate memory before crew starts
memory.set("priority_accounts", ["Acme Corp", "TechStart Inc"])

# Check what agents learned after crew finishes
learned_facts = memory.get("competitor_analysis")
print(f"Agents discovered: {learned_facts}")

Memory persists across processes, machines, and time. Your agents build institutional knowledge.

CrewAI Integration Patterns

For complex crews, create memory hierarchies and shared knowledge:

from crewai import Crew, Agent, Task
from botwire.memory import memory_tools

# Shared crew memory + individual agent memory
shared_tools = memory_tools("project-alpha-shared")
researcher_tools = memory_tools("project-alpha-researcher") 
writer_tools = memory_tools("project-alpha-writer")

researcher = Agent(
    role="Senior Researcher",
    goal="Gather comprehensive market data",
    tools=shared_tools + researcher_tools  # Access both memory spaces
)

writer = Agent(
    role="Technical Writer", 
    goal="Create reports based on research",
    tools=shared_tools + writer_tools  # Can read researcher's shared findings
)

research_task = Task(
    description="""Research cloud security trends. 
    Store key findings in shared memory for the writer.
    Track your research methodology in your personal memory.""",
    agent=researcher
)

writing_task = Task(
    description="""Check shared memory for research findings.
    Write a comprehensive report. Save draft versions as you work.""",
    agent=writer
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    process="sequential"  # Writer builds on researcher's stored findings
)

result = crew.kickoff()

When NOT to Use BotWire

BotWire isn't the right tool for:

FAQ

Why not just use Redis or a database? You absolutely can. BotWire is for developers who want persistent memory without infrastructure setup. It's free, requires no configuration, and has CrewAI helpers built-in.

Is this actually free? Yes. 1000 writes per day per namespace, 50MB storage per namespace, unlimited reads. No credit card, no signup friction. Open source MIT license.

What about data privacy? Data flows through botwire.dev's API. If you need full control, self-host the open source FastAPI service from the GitHub repo. It's just SQLite + HTTP.

Get Started

Give your CrewAI agents persistent memory across sessions. Install BotWire and your agents will never forget again.

pip install botwire

Full documentation and self-hosting instructions at https://botwire.dev.

Install in one command:

pip install botwire

Start free at botwire.dev