Adapters

CrewAI

Use MemexAI memory tools with CrewAI in Python.

The CrewAI adapter returns MemexAI tools as @tool-decorated async functions compatible with CrewAI agents.

Before you start

Install

pip install memexai crewai

Usage

from memexai import MemexAI
from memexai.adapters.crewai import get_crewai_tools
from crewai import Agent, Task, Crew

memex = MemexAI(url="http://localhost:8080", api_key="dev-agent-key")
user = memex.for_user("user_123", actor="assistant")
tools = get_crewai_tools(user)

assistant = Agent(
    role="Personal Assistant",
    goal="Maintain durable memory about the user across sessions.",
    backstory="You remember what matters and surface it when it's relevant.",
    tools=tools,
    verbose=True,
)

task = Task(
    description="Remember that the user prefers quiet neighborhoods near good schools.",
    expected_output="Confirmation that the preference was saved to memory.",
    agent=assistant,
)

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

await memex.close()

Available tools

get_crewai_tools returns seven @tool-decorated async functions. Each wraps the corresponding MemexUser method:

ToolPurpose
memory_listList files visible to the current user
memory_readRead a single file by virtual path
memory_writeCreate or overwrite a user file
memory_patchApply targeted updates (append, replace)
memory_smart_readRead all memory into a bounded context block
memory_searchBM25 full-text search over memory
memory_memorizeFeed raw text and let MemexAI decide what to write

This example exposes all tools so you can see the full adapter shape. For a minimal production setup, assign only memory_memorize and memory_search to the agent. Include the full set when a task requires direct file control.

On this page