Skip to main content
Integrate Honcho with CrewAI to build AI agents that maintain memory across sessions. This guide shows you how to use Honcho’s memory layer with CrewAI’s agent orchestration framework.
The full code is available on GitHub with examples in Python

What We’re Building

We’ll create AI agents that remember and reason over past conversations. Here’s how the pieces fit together:
  • CrewAI orchestrates agent behavior and task execution
  • Honcho stores messages and retrieves relevant context
The key benefit: CrewAI automatically retrieves relevant conversation history from Honcho without you needing to manually manage context, token limits, or message formatting.
This tutorial demonstrates single-agent setup to show how Honcho integrates with CrewAI. For production applications, you can extend this to multi-agent crews with shared or individual memory using Honcho’s peer system.

Setup

Install required packages:
Use any LLM provider for your Crew. Create a .env file with your API keys:
This tutorial uses the Honcho demo server at https://demo.honcho.dev which runs a small instance of Honcho on the latest version. For production, get your Honcho API key at app.honcho.dev. For local development, use environment="local".

CrewAI Honcho Storage

The honcho_crewai package provides HonchoStorage, a storage provider that implements CrewAI’s Storage interface using Honcho’s session-based memory.
Before proceeding, it’s important to understand Honcho’s core concepts (Peers and Sessions). Review the Honcho Architecture to familiarize yourself with these primitives.
HonchoStorage implements CrewAI’s Storage interface using Honcho’s peer and session primitives.
The HonchoStorage class implements three key methods:
  • save() - Stores messages in Honcho’s session, associating them with the appropriate peer (user or assistant)
  • search() - Performs semantic vector search using session.search() to find messages most relevant to the query. Supports optional filters parameter for fine-grained scoping.
  • reset() - Creates a new session to start fresh conversations
CrewAI automatically calls these methods when agents need to store or retrieve memory, creating a seamless integration.

Search with Filters

The search() method supports an optional filters parameter for fine-grained scoping of search results:
For the full filter syntax including logical operators (AND, OR, NOT), comparison operators, and metadata filtering, see the Using Filters documentation.
For comprehensive details about CrewAI’s memory system, see the official CrewAI Memory documentation.
Let’s create a basic example showing how CrewAI agents use Honcho’s memory automatically:
Python

CrewAI Tool Integration

Honcho provides specialized tools that give CrewAI agents explicit control over memory retrieval:
  • HonchoGetContextTool - Retrieves comprehensive conversation history with token limits. Use for tasks needing broad conversation understanding.
  • HonchoDialecticTool - Queries representations about peers. Use for understanding user preferences and characteristics without full message history.
  • HonchoSearchTool - Performs semantic search for specific information. Supports optional filters parameter for fine-grained scoping. Use for targeted queries like “what did the user say about budget?”
Agents can use multiple tools in sequence: search for topics, query dialectic for preferences, then get full context for generation.
Here’s an example demonstrating all three tools:
Python

Tool-Based vs Automatic Memory

Use HonchoStorage for automatic memory - CrewAI handles everything transparently. Best for simple conversational flows. Use Honcho Tools for strategic control - agents decide when and how to query memory. Best for multi-step reasoning, when different query types are needed, or multi-agent systems. You can combine both: automatic memory for baseline context, tools for specific queries. See the hybrid memory example for a complete implementation.
Multi-Agent Memory: Use Honcho tools with different peer_id values to give each agent distinct memory and identity.

Next Steps

Now that you have a working CrewAI integration with Honcho, you can:
  • Create specialized agents with domain-specific memory and context
  • Use CrewAI’s advanced features like hierarchical processes, tool delegation, and conditional task execution
  • Leverage logical reasoning via the Dialectic API for deep peer understanding
  • Implement custom tools to give agents explicit control over memory retrieval

Honcho Architecture

Understand Honcho’s peer-based model and core primitives

Get Context

Learn about retrieving and formatting conversation context

Dialectic API

Query peer representations for deeper understanding

LangGraph Integration

Build stateful agents with LangGraph and Honcho