Miscellaneous

Miscellaneous

Give Your AI Agent Persistent Memory in Under 5 Seconds

| • Updated:

| • Updated:

Most agent sessions start cold. Every project context, user preference, and past decision disappears when the process exits. Adding a persistent memory layer has always required a human to stop, authenticate, and configure an external service before the agent can store its first fact.

One command removes that requirement.

mem0 init --agent --agent-caller "claude-code" --json
mem0 init --agent --agent-caller "claude-code" --json
mem0 init --agent --agent-caller "claude-code" --json

The response comes back in under five seconds:

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

No email. No browser. No human in the loop.

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


Why Persistent Memory Matters

Persistent memory is facts, preferences, and context that survive session boundaries. Without it, agents are stateless by design, and stateless agents repeat themselves.

Three failure modes that show up consistently.

A support agent asks a returning user for their account details on session four. The user answered those questions in session one. The agent has no record of it. A coding agent asks about type annotation preferences at the start of every project conversation, regardless of how many times the developer has already answered. A research agent repeats a failed approach from last week because it has no record of what it tried, why it failed, or what the outcome was.

Each of these is not a limitation of the agent's reasoning. It is a missing write operation after each session and a missing read operation before the next one.


What Setup Used to Require

Connecting any cloud memory service to an autonomous agent has followed the same path: open a browser, enter an email address, wait for a verification link, create an organization, generate an API key, copy it to the clipboard, paste it into .env. Ten to fifteen minutes for a developer doing it manually. For an autonomous agent running unattended, impossible at step one.

Two scenarios where that block is acute.

Agents in CI/CD pipelines. An agent running across job runs needs persistent context. No human is present to complete a verification flow. Without Agent Mode, the agent either shares a hardcoded key with every other agent on the team, collapsing isolation, or skips memory entirely.

On-demand agent spawning. Systems that create one agent instance per user session need per-agent credential isolation at scale. A human-gated signup form makes that impractical. Agent Mode provisions an isolated key per agent in the same time it takes to make an API call.


What Each Field Gives the Agent

api_key is a working Mem0 API key scoped to an isolated project. Use it immediately with the Mem0 SDK or MCP server. No additional setup required.

default_user_id is a stable identifier for scoping memories to this agent across sessions. Every memory stored under this ID is retrievable in future runs.

mcp_url is a ready-to-use MCP endpoint. Drop it into Claude Code, Cursor, Cline, or any MCP-compatible client and memory tools are available as first-class capabilities in the agent's environment.

claim_command is for when a human wants to attach their account. Running mem0 init --email [email protected] transfers ownership atomically. The key does not change. All memories stay intact.

Credentials are written to ~/.mem0/config.json and reused on every subsequent run without re-provisioning.


How Mem0 Is Different

Most approaches to agent memory store raw text or embeddings and leave retrieval to the developer. Mem0 handles the extraction, storage, and retrieval layer as a managed service.

Fact extraction, not raw storage. When the agent passes a conversation to client.add(), Mem0 extracts structured facts rather than storing the raw exchange. "I'm building a FastAPI service with PostgreSQL" becomes a clean, retrievable memory. The agent does not need to design a schema or write extraction logic.

Semantic search with relevance scoring. client.search() returns semantically ranked results with a score field per result. The agent surfaces what is relevant to the current context, not everything ever stored.

Cloud-hosted across environments. Memories survive container restarts, CI environment teardowns, and machine changes. A coding agent in a GitHub Actions job and a developer's local session share the same memory if they use the same key and user ID.

Per-agent isolation by default. Each Agent Mode key owns its own isolated project. No configuration needed to keep one agent's memories separate from another's.

Agent-native provisioning. The only step that previously required a human was getting the API key. Agent Mode removes that step entirely.


From Key to First Memory

from mem0 import MemoryClient

# api_key comes from mem0 init --agent --json
client = MemoryClient(api_key="m0-...")
user_id = "user_a1b2c3d4"  # default_user_id from the init response

# Store context from this session
client.add([
    {"role": "user", "content": "I'm building a FastAPI service with PostgreSQL"}
], user_id=user_id)

# Next session: retrieve relevant context before responding
results = client.search("what is the user building?", user_id=user_id)
for r in results:
    print(r["memory"])    # "User is building a FastAPI service with PostgreSQL"
    print(r["score"])     # semantic relevance score
from mem0 import MemoryClient

# api_key comes from mem0 init --agent --json
client = MemoryClient(api_key="m0-...")
user_id = "user_a1b2c3d4"  # default_user_id from the init response

# Store context from this session
client.add([
    {"role": "user", "content": "I'm building a FastAPI service with PostgreSQL"}
], user_id=user_id)

# Next session: retrieve relevant context before responding
results = client.search("what is the user building?", user_id=user_id)
for r in results:
    print(r["memory"])    # "User is building a FastAPI service with PostgreSQL"
    print(r["score"])     # semantic relevance score
from mem0 import MemoryClient

# api_key comes from mem0 init --agent --json
client = MemoryClient(api_key="m0-...")
user_id = "user_a1b2c3d4"  # default_user_id from the init response

# Store context from this session
client.add([
    {"role": "user", "content": "I'm building a FastAPI service with PostgreSQL"}
], user_id=user_id)

# Next session: retrieve relevant context before responding
results = client.search("what is the user building?", user_id=user_id)
for r in results:
    print(r["memory"])    # "User is building a FastAPI service with PostgreSQL"
    print(r["score"])     # semantic relevance score

Full API reference: docs.mem0.ai/platform/quickstart


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