Miscellaneous

Miscellaneous

How to Enable Memory in Your Agentic Stack with a Single Command

| • Updated:

| • Updated:

The hard part of adding memory to an autonomous agent is not writing the integration code. It is getting credentials into the agent's environment before any code can run. Every cloud memory service requires a human to sign up, verify an email, generate a key, and paste it somewhere. Agents cannot do any of those steps.


Where the Setup Process Breaks

Two scenarios show exactly where this fails.

Scenario 1: A LangGraph agent mid-session. The agent is helping a developer debug a production incident. It needs context from two weeks ago but has no memory of it. The developer adds a Mem0 memory node to the graph. The SDK returns a 401. The API key is not in the environment. The developer has to stop the session, open a browser, complete email verification, copy the key, and restart. The agent could not provision that credential itself at any step.

Scenario 2: A CrewAI agent that hits a signup form. The agent is evaluating five developer APIs for a given capability. It reads docs, generates integration code, and calls each API's provisioning endpoint. Four return an HTML page or a redirect to a signup form. The agent can parse JSON. It cannot fill out a form or receive a verification email. The workflow stops before it can do the actual work.

Both scenarios share the same root cause: credential provisioning was designed for a human in a browser.


Framework Memory Has Limits

LangGraph and CrewAI both have memory capabilities. LangGraph checkpointers store state in Postgres or SQLite local to the deployment. CrewAI's memory system stores context in LanceDB on the same machine. Both work well within a single environment.

When an agent needs memory that survives environment resets, works across different machines, or stays isolated per agent instance without manual configuration, local storage is not enough. Mem0 stores memories in the cloud, retrieves them with semantic search, and isolates them per agent by default. The same API key works in a GitHub Actions job, a developer's local session, and a production container.


One Command

mem0 init --agent --agent-caller "your-tool-name" --json
mem0 init --agent --agent-caller "your-tool-name" --json
mem0 init --agent --agent-caller "your-tool-name" --json

Install once:

npm install -g @mem0/cli
# or
pip install mem0ai
npm install -g @mem0/cli
# or
pip install mem0ai
npm install -g @mem0/cli
# or
pip install mem0ai

The command runs in under 5 seconds and returns a JSON envelope with everything the agent needs:

{
  "api_key": "m0-...",
  "default_user_id": "user_...",
  "mcp_url": "https://mcp.mem0.ai/mcp",
  "claim_command": "mem0 init --email [email protected]"
}
{
  "api_key": "m0-...",
  "default_user_id": "user_...",
  "mcp_url": "https://mcp.mem0.ai/mcp",
  "claim_command": "mem0 init --email [email protected]"
}
{
  "api_key": "m0-...",
  "default_user_id": "user_...",
  "mcp_url": "https://mcp.mem0.ai/mcp",
  "claim_command": "mem0 init --email [email protected]"
}

Each call creates a standalone shadow account with its own isolated (Organization, Project, APIKey) trio. No email address, no usable password. Two calls on two machines produce two fully independent accounts. Credentials are written to ~/.mem0/config.json and reused on every subsequent run.


Adding Mem0 to Your Framework

LangGraph

Add a memory retrieval step before each LLM call and a storage step after. The agent carries relevant context from past sessions automatically.


from mem0 import MemoryClient

client = MemoryClient(api_key="m0-...")  # key from mem0 init --agent --json

# In your chatbot node: retrieve before responding
memories = client.search(user_message, user_id=state["mem0_user_id"])
context = "\n".join([m["memory"] for m in memories])

# After responding: store the exchange
client.add(messages, user_id=state["mem0_user_id"])
from mem0 import MemoryClient

client = MemoryClient(api_key="m0-...")  # key from mem0 init --agent --json

# In your chatbot node: retrieve before responding
memories = client.search(user_message, user_id=state["mem0_user_id"])
context = "\n".join([m["memory"] for m in memories])

# After responding: store the exchange
client.add(messages, user_id=state["mem0_user_id"])
from mem0 import MemoryClient

client = MemoryClient(api_key="m0-...")  # key from mem0 init --agent --json

# In your chatbot node: retrieve before responding
memories = client.search(user_message, user_id=state["mem0_user_id"])
context = "\n".join([m["memory"] for m in memories])

# After responding: store the exchange
client.add(messages, user_id=state["mem0_user_id"])

Full integration guide: docs.mem0.ai/integrations/langgraph


CrewAI

Pass Mem0 as the memory provider in the Crew configuration. CrewAI handles the add and search calls automatically during task execution.

crew = Crew(
    agents=[...],
    tasks=[...],
    memory=True,
    memory_config={
        "provider": "mem0",
        "config": {"user_id": "crew_user_1"}
    }
)
crew = Crew(
    agents=[...],
    tasks=[...],
    memory=True,
    memory_config={
        "provider": "mem0",
        "config": {"user_id": "crew_user_1"}
    }
)
crew = Crew(
    agents=[...],
    tasks=[...],
    memory=True,
    memory_config={
        "provider": "mem0",
        "config": {"user_id": "crew_user_1"}
    }
)

Full integration guide: docs.mem0.ai/integrations/crewai


MCP Clients
For Claude Code, Cursor, Cline, or any MCP-compatible client, drop the mcp_url from the init response directly into the server configuration. Memory tools become available immediately without any SDK code.


Claim When Ready

When a developer wants dashboard access or billing controls, one command transfers ownership:

The API key does not change. All accumulated memories remain intact. The agent continues without any reconfiguration.


Supported Environments

Works in Claude Code, Cursor, Codex, Cline, Continue, Aider, Goose, and Windsurf. The --agent-caller flag is optional and sets per-caller attribution in the dashboard.

Credentials are written to ~/.mem0/config.json and reused across sessions without re-provisioning.

Full documentation: docs.mem0.ai/platform/agent-signup


Mem0 is an intelligent, open-source memory layer designed for LLMs and AI agents.

If you are a human: Get your free API key at app.mem0.ai

If you are an agent:

mem0 init --agent --agent-caller "your-tool-name"
mem0 init --agent --agent-caller "your-tool-name"
mem0 init --agent --agent-caller "your-tool-name"

Or self-host from our open source GitHub repository

GET TLDR from:

Summarize

Website/Footer

Summarize

Website/Footer

Summarize

Website/Footer

Summarize

Website/Footer