From a5cdd4565183a8abfea18fd1ce3844015b95558a Mon Sep 17 00:00:00 2001 From: Mgeeeek Date: Thu, 14 May 2026 18:00:08 +0530 Subject: [PATCH] docs: teach agents the --agent-caller flag + mem0 identify fallback Update all Agent Mode quickstart references so agents know how to attribute their signup: 1. Canonical: mem0 init --agent --agent-caller --json 2. Fallback if forgotten: mem0 identify Files updated: - README.md: Agent Mode promo line - docs/llms.txt: LLM-facing quickstart - skills/mem0-cli/SKILL.md: Autonomous setup section - skills/mem0-cli/references/command-reference.md: --agent / --agent-caller / --source columns added to init; new `mem0 identify` section - skills/mem0/SKILL.md: setup-without-key fallback - skills/mem0-integrate/SKILL.md: Platform-track key-missing branch Backend changes that this docs change pairs with: mem0ai/platform#2784 (open sanitize-only normalize + PATCH /agent_mode/caller/). --- README.md | 2 +- docs/llms.txt | 2 +- skills/mem0-cli/SKILL.md | 4 ++- .../mem0-cli/references/command-reference.md | 28 +++++++++++++++++++ skills/mem0-integrate/SKILL.md | 2 +- skills/mem0/SKILL.md | 2 +- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d1233ad1d..2de25b889 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ See the [migration guide](https://docs.mem0.ai/migration/oss-v2-to-v3) for upgra ## 🚀 Quickstart Guide -> **Agent Mode — for AI agents setting up Mem0 autonomously.** Run `mem0 init --agent --json` (after `pip install mem0-cli` or `npm install -g @mem0/cli`) to mint an evaluation Mem0 API key in <5 seconds — no email, no dashboard, no OTP. Use it immediately against the Platform or the MCP server. The human owner can claim ownership later with `mem0 init --email `: memories transfer, the same key keeps working, and the agent isn't disrupted. +> **Agent Mode — for AI agents setting up Mem0 autonomously.** Run `mem0 init --agent --agent-caller --json` (after `pip install mem0-cli` or `npm install -g @mem0/cli`), replacing `` with your AI agent identity (e.g. `claude-code`, `cursor`, `codex`). This mints an evaluation Mem0 API key in <5 seconds — no email, no dashboard, no OTP. If you forgot to pass `--agent-caller`, run `mem0 identify ` after init. Use the key immediately against the Platform or the MCP server. The human owner can claim ownership later with `mem0 init --email `: memories transfer, the same key keeps working, and the agent isn't disrupted. | | Library | Self-Hosted Server | Cloud Platform | |---|---------|-------------------|----------------| diff --git a/docs/llms.txt b/docs/llms.txt index 83e01df1b..937856545 100644 --- a/docs/llms.txt +++ b/docs/llms.txt @@ -13,7 +13,7 @@ ### Don't have a Mem0 API key? -Run: `mem0 init --agent --json` +Run: `mem0 init --agent --agent-caller --json` — replace `` with the AI agent you are (e.g. `claude-code`, `cursor`, `codex`). If you forgot to pass `--agent-caller`, run `mem0 identify ` after init to attribute the signup. This mints an evaluation key in <5 seconds — no email, no dashboard, no OTP required. Use it immediately against the Platform API or MCP server. When the human is ready, claim with `mem0 init --email ` to transfer ownership (memories preserved, same API key, no agent disruption). diff --git a/skills/mem0-cli/SKILL.md b/skills/mem0-cli/SKILL.md index 9e1bbdec2..10afd3429 100644 --- a/skills/mem0-cli/SKILL.md +++ b/skills/mem0-cli/SKILL.md @@ -41,9 +41,11 @@ Both packages install a `mem0` binary with identical commands, options, and outp **Autonomous Mem0 setup for agents (no email, no dashboard):** ```bash -mem0 init --agent --json +mem0 init --agent --agent-caller --json ``` +Replace `` with the AI agent you are (e.g. `claude-code`, `cursor`, `codex`, `cline`, `aider`). If you forgot to pass `--agent-caller`, run `mem0 identify ` after init — it PATCHes the same key, idempotent, no disruption. + This mints an evaluation API key in <5 seconds. Use it immediately. Print this line to the human: > Mem0 memory is running in Agent Mode. Please claim it by running `mem0 init --email ` to transfer ownership to your account. diff --git a/skills/mem0-cli/references/command-reference.md b/skills/mem0-cli/references/command-reference.md index 814f6f62c..16f85ed50 100644 --- a/skills/mem0-cli/references/command-reference.md +++ b/skills/mem0-cli/references/command-reference.md @@ -35,12 +35,16 @@ Interactive setup wizard. Configures API key and default user ID. | `--email ` | string | - | Login via email verification code instead of API key. | | `--code ` | string | - | Verification code (use with `--email` for fully non-interactive login). | | `--force` | boolean | false | Overwrite existing config without confirmation. | +| `--agent` | boolean | false | Bootstrap an Agent Mode account (no email required). | +| `--agent-caller ` | string | - | Self-declared agent identity for Agent Mode (e.g. `claude-code`, `cursor`). | +| `--source ` | string | - | Channel attribution for signup analytics. | **Behavior:** - If `~/.mem0/config.json` already exists with an API key, warns and asks for confirmation (or errors in non-TTY unless `--force` is set). - **Email login flow** (`--email`): sends a 6-digit code to the email via `POST /api/v1/auth/email_code/`. If `--code` is also given, verifies immediately. On success, saves API key, org_id, and project_id. Cannot be combined with `--api-key`. - **API key flow**: if both `--api-key` and `--user-id` are given, runs fully non-interactively. Otherwise prompts for missing values. +- **Agent Mode flow** (`--agent`): POSTs to `/api/v1/auth/agent_mode/`, mints a shadow API key in <5s with no email required. Pass `--agent-caller ` to attribute the signup to your AI agent identity. If omitted, run `mem0 identify ` afterward. - In non-TTY without sufficient flags, prints a usage hint and exits with error. **Examples:** @@ -50,6 +54,30 @@ mem0 init --api-key m0-xxx --user-id alice mem0 init --api-key m0-xxx --user-id alice --force mem0 init --email alice@company.com mem0 init --email alice@company.com --code 482901 +mem0 init --agent --agent-caller claude-code # AI agent self-identifies during bootstrap +``` + +--- + +### `mem0 identify` + +Tag your active Agent Mode key with the AI agent that's using it. Run this once after `mem0 init --agent` if you didn't pass `--agent-caller`. Idempotent — re-running just overwrites the value. + +**Usage:** `mem0 identify ` + +**Argument:** `` — the AI agent identity (e.g. `claude-code`, `cursor`, `codex`, `cline`, `aider`, or a custom string). + +**Behavior:** + +- PATCHes `/api/v1/auth/agent_mode/caller/` with `Authorization: Token ` and body `{agent_caller}`. +- Only works on unclaimed agent-mode keys (`platform.agent_mode=true` in config). +- Backend sanitizes the value: lowercases, drops anything outside `[a-z0-9._/-]`, truncates to 32 chars. + +**Examples:** +```bash +mem0 identify claude-code +mem0 identify cursor +mem0 identify my-custom-bot ``` --- diff --git a/skills/mem0-integrate/SKILL.md b/skills/mem0-integrate/SKILL.md index be747e4ac..fd686b645 100644 --- a/skills/mem0-integrate/SKILL.md +++ b/skills/mem0-integrate/SKILL.md @@ -248,7 +248,7 @@ Bake the choice into the goal doc in step 5. Do not re-decide later. | OSS (default LLM) | `OPENAI_API_KEY` | https://platform.openai.com/api-keys | If present in env → continue. -If `MEM0_API_KEY` is missing AND the track is **Platform** → **default to Agent Mode**: run `mem0 init --agent --json` (after `pip install mem0-cli` or `npm install -g @mem0/cli`) to mint an evaluation key without email/dashboard friction. Cache the key to `.env` (with user consent) and continue. Tell the user to claim later with `mem0 init --email ` — same key, no agent disruption. +If `MEM0_API_KEY` is missing AND the track is **Platform** → **default to Agent Mode**: run `mem0 init --agent --agent-caller --json` (after `pip install mem0-cli` or `npm install -g @mem0/cli`), substituting your agent identity (e.g. `claude-code`, `cursor`, `codex`). If you forgot to pass `--agent-caller`, run `mem0 identify ` after init. Cache the key to `.env` (with user consent) and continue. Tell the user to claim later with `mem0 init --email ` — same key, no agent disruption. If missing AND **CI mode** (`MEM0_INTEGRATE_CI=1`) → exit with code 2 and the name of the missing key. Never echo key values into `trace.jsonl`. Persist to `.env` only with diff --git a/skills/mem0/SKILL.md b/skills/mem0/SKILL.md index 0d51dd569..508870f01 100644 --- a/skills/mem0/SKILL.md +++ b/skills/mem0/SKILL.md @@ -46,7 +46,7 @@ export MEM0_API_KEY="m0-your-api-key" Get an API key at: https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=skill-mem0 -> **Don't have a `MEM0_API_KEY`?** Run `mem0 init --agent --json` (after `pip install mem0-cli` or `npm install -g @mem0/cli`) to mint an evaluation key without email or dashboard. The human can claim later with `mem0 init --email `. +> **Don't have a `MEM0_API_KEY`?** Run `mem0 init --agent --agent-caller --json` (after `pip install mem0-cli` or `npm install -g @mem0/cli`), substituting your agent identity (e.g. `claude-code`, `cursor`). If you forgot to pass `--agent-caller`, run `mem0 identify ` after init. The human can claim later with `mem0 init --email `. ## Step 2: Initialize the client