feat(mem0-plugin): v0.2.6 — fix memory visibility, remove redundant hooks, reduce latency (#5257)
This commit is contained in:
@@ -14,8 +14,8 @@ All endpoints require: `Authorization: Token <MEM0_API_KEY>`
|
||||
| Get Single Memory | `GET` | `/v1/memories/{memory_id}/` |
|
||||
| Update Memory | `PUT` | `/v1/memories/{memory_id}/` |
|
||||
| Delete Memory | `DELETE` | `/v1/memories/{memory_id}/` |
|
||||
|
||||
Note: v1/v2 endpoints still work (backward compatible).
|
||||
| Delete All Memories | `DELETE` | `/v1/memories/?user_id=X&app_id=Y` |
|
||||
| Get Event Status | `GET` | `/v1/event/{event_id}/` |
|
||||
|
||||
## Memory Object Structure
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ console.log(results);
|
||||
export MEM0_API_KEY="m0-your-api-key"
|
||||
|
||||
# Add memory
|
||||
curl -X POST https://api.mem0.ai/v1/memories/ \
|
||||
curl -X POST https://api.mem0.ai/v3/memories/add/ \
|
||||
-H "Authorization: Token $MEM0_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
|
||||
@@ -21,10 +21,10 @@ This is silent and idempotent — safe to run anytime.
|
||||
|
||||
## Step 1: Set up API key
|
||||
|
||||
Check if `MEM0_API_KEY` is already set by running:
|
||||
Check if the API key is available from any source:
|
||||
|
||||
```bash
|
||||
[ -n "$MEM0_API_KEY" ] && echo "SET" || echo "NOT_SET"
|
||||
[ -n "${MEM0_API_KEY:-${CLAUDE_PLUGIN_OPTION_API_KEY:-}}" ] && echo "SET" || echo "NOT_SET"
|
||||
```
|
||||
|
||||
IMPORTANT: Never run `echo $MEM0_API_KEY` — that prints the secret in plaintext to the conversation log.
|
||||
@@ -33,27 +33,32 @@ IMPORTANT: Never run `echo $MEM0_API_KEY` — that prints the secret in plaintex
|
||||
|
||||
Print: `- API key found.` and proceed to Step 2.
|
||||
|
||||
### If API key is NOT set (empty output)
|
||||
### If API key is NOT set (output is "NOT_SET")
|
||||
|
||||
Guide the user through API key setup. Show this message and walk them through it:
|
||||
Guide the user through API key setup. Show this message:
|
||||
|
||||
```
|
||||
Step 1: Setting up API key.
|
||||
|
||||
- MEM0_API_KEY not found. Let's set it up.
|
||||
- API key not found. Let's set it up.
|
||||
|
||||
1. Get your API key from https://app.mem0.ai/dashboard/api-keys
|
||||
(or run: mem0 init --agent --json)
|
||||
|
||||
2. Add to shell profile:
|
||||
echo 'export MEM0_API_KEY="m0-your-key-here"' >> ~/.zshrc
|
||||
source ~/.zshrc
|
||||
2. Choose ONE method:
|
||||
|
||||
Option A — Plugin config (works on Desktop + CLI):
|
||||
Type: ! claude plugin configure mem0
|
||||
Paste your API key when prompted.
|
||||
|
||||
Option B — Shell profile (CLI only):
|
||||
echo 'export MEM0_API_KEY="m0-your-key-here"' >> ~/.zshrc
|
||||
source ~/.zshrc
|
||||
|
||||
3. Verify:
|
||||
[ -n "$MEM0_API_KEY" ] && echo "SET" || echo "NOT_SET"
|
||||
[ -n "${MEM0_API_KEY:-${CLAUDE_PLUGIN_OPTION_API_KEY:-}}" ] && echo "SET" || echo "NOT_SET"
|
||||
```
|
||||
|
||||
After the user confirms they've set the key, verify it by running `[ -n "$MEM0_API_KEY" ] && echo "SET" || echo "NOT_SET"`. If NOT_SET, repeat the instructions. If SET, proceed to Step 2.
|
||||
After the user confirms, re-run the verify command. If NOT_SET, repeat. If SET, proceed to Step 2.
|
||||
|
||||
## Step 2: MCP server connection
|
||||
|
||||
|
||||
@@ -25,24 +25,23 @@ If the script returns empty or errors, note "No session data available" and cont
|
||||
### Step 2: Fetch lifetime and session stats from API
|
||||
|
||||
**Lifetime stats:**
|
||||
Call `get_memories` with:
|
||||
- `filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}`
|
||||
- `page_size=100`
|
||||
Call `get_memories` to fetch all memories for this project:
|
||||
|
||||
Count the returned memories. Group them by:
|
||||
`filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}`, `page_size=100`
|
||||
|
||||
Group by:
|
||||
1. `categories[0]` (platform-assigned) — primary grouping
|
||||
2. `metadata.type` (agent-assigned) — secondary if no categories
|
||||
3. `created_at` date — for age analysis
|
||||
|
||||
**Session stats (API-backed):**
|
||||
Read the session ID file at `/tmp/mem0_session_id_$USER`. If it exists and contains
|
||||
a non-empty value, also call `get_memories` with:
|
||||
- `filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}, {"run_id": "<session_id>"}]}`
|
||||
- `page_size=100`
|
||||
**Category normalization:** Merge `auto_capture` and `uncategorized` into a single `uncategorized` row. These are memories where the platform didn't assign a meaningful content category. Do NOT show `auto_capture` as its own row in the table.
|
||||
|
||||
This returns only memories written in the current session. Use this count to
|
||||
cross-check the local stats file. If the API count is higher, use the API count
|
||||
(the local tracker may have missed operations).
|
||||
**Session stats (local only):**
|
||||
Session stats come from the local stats file read in Step 1. Do NOT query the API with
|
||||
`run_id` or `metadata.session_id` filters — these return unreliable results because
|
||||
memories are stored without `run_id` and metadata filters on `session_id` are inconsistent.
|
||||
|
||||
The local stats file tracks adds and searches for the current session accurately.
|
||||
|
||||
Also run a `search_memories` MCP tool call with `query="project"`, `filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}`, `top_k=1` to measure round-trip latency. Note the time before and after the MCP call — do NOT attempt raw HTTP calls to the API.
|
||||
|
||||
|
||||
@@ -56,11 +56,9 @@ If no query argument and no `--all-projects` flag, use the full tour flow below.
|
||||
|
||||
### Step 1: Fetch ALL memories for this project
|
||||
|
||||
Call `get_memories` with:
|
||||
- `filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}`
|
||||
- `page_size=100`
|
||||
Call `get_memories` to fetch all memories for this project:
|
||||
|
||||
This returns every memory scoped to the project — no semantic filtering, no missed results.
|
||||
`filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}`, `page_size=100`
|
||||
|
||||
### Step 2: Run supplementary semantic searches
|
||||
|
||||
|
||||
Reference in New Issue
Block a user