fix(plugin): correct v2 filter syntax in mem0-mcp rubric
The rubric introduced in this PR taught the agent to use
`{"metadata.type": "decision"}` filters, but the v2 search
contract (docs/platform/features/v2-memory-filters.mdx) requires:
1. The root must be a logical operator (`AND`/`OR`/`NOT`) with an array.
A bare `{"user_id": "..."}` is rejected.
2. Metadata uses a nested object — `{"metadata": {"type": "..."}}` —
not a dotted key. Only top-level metadata keys are filterable.
Without this fix, agents following the rubric produce filter calls
the platform either ignores or rejects.
Also replaces the literal `"alice"` in the worked example with a
clearly-marked `<your_user_id>` placeholder so agents don't copy
verbatim, and adds a one-line "substitute the active user_id"
instruction.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,12 +51,14 @@ improve your answer. The agent -- not this hook -- owns this decision.
|
||||
- Run **2-4 parallel** \`search_memories\` calls with different angles, not one
|
||||
query that echoes the user's prompt.
|
||||
- Phrase queries as **nouns** ("auth module decisions"), not full sentences.
|
||||
- Use \`metadata.type\` filters where they fit:
|
||||
- \`{"metadata.type": "decision"}\` -- design / architecture questions
|
||||
- \`{"metadata.type": "anti_pattern"}\` -- debugging, error handling
|
||||
- \`{"metadata.type": "user_preference"}\` -- tooling, stack, style
|
||||
- \`{"metadata.type": "convention"}\` -- established patterns in this project
|
||||
- Scope every query with \`{"user_id": "$USER_ID"}\`.
|
||||
- Filter shape: the root must be a logical operator (\`AND\` / \`OR\` / \`NOT\`)
|
||||
with an array, and metadata uses a **nested** object (not dotted keys).
|
||||
Combine \`user_id\` with one \`metadata.type\` clause per call:
|
||||
- \`{"AND": [{"user_id": "$USER_ID"}, {"metadata": {"type": "decision"}}]}\` -- design / architecture
|
||||
- \`{"AND": [{"user_id": "$USER_ID"}, {"metadata": {"type": "anti_pattern"}}]}\` -- debugging, error handling
|
||||
- \`{"AND": [{"user_id": "$USER_ID"}, {"metadata": {"type": "user_preference"}}]}\` -- tooling, stack, style
|
||||
- \`{"AND": [{"user_id": "$USER_ID"}, {"metadata": {"type": "convention"}}]}\` -- established patterns
|
||||
- Or scope with just \`{"AND": [{"user_id": "$USER_ID"}]}\` when no metadata filter fits.
|
||||
- Empty results are normal -- proceed without context.
|
||||
EOF
|
||||
|
||||
|
||||
@@ -43,18 +43,25 @@ When you do search, run **2–4 parallel** `search_memories` calls at different
|
||||
- Use entity names, not pronouns. Resolve "that thing" from recent context first.
|
||||
- Don't search on meta-questions ("what was that?") — use recent context or `get_memories` ordered by `created_at`.
|
||||
|
||||
**Metadata filters** match the same `metadata.type` values written under "After completing significant work" below:
|
||||
**Metadata filters** match the same `type` values written under "After completing significant work" below.
|
||||
|
||||
| Filter | Use for |
|
||||
Two rules from the v2 filter spec:
|
||||
|
||||
1. The root **must** be a logical operator (`AND` / `OR` / `NOT`) with an array. A bare `{"user_id": "..."}` won't work.
|
||||
2. Metadata uses a **nested** object, not a dotted key. `{"metadata": {"type": "decision"}}`, never `{"metadata.type": "decision"}`. Only top-level metadata keys are filterable.
|
||||
|
||||
Combine `user_id` with one metadata clause per call:
|
||||
|
||||
| `metadata.type` clause | Use for |
|
||||
|--------|---------|
|
||||
| `{"metadata.type": "decision"}` | design / architecture / "how should we" questions |
|
||||
| `{"metadata.type": "anti_pattern"}` | debugging, error handling, things that failed before |
|
||||
| `{"metadata.type": "user_preference"}` | tooling, stack, style — always include for code work |
|
||||
| `{"metadata.type": "convention"}` | established patterns in this project |
|
||||
| `{"metadata": {"type": "decision"}}` | design / architecture / "how should we" questions |
|
||||
| `{"metadata": {"type": "anti_pattern"}}` | debugging, error handling, things that failed before |
|
||||
| `{"metadata": {"type": "user_preference"}}` | tooling, stack, style — always include for code work |
|
||||
| `{"metadata": {"type": "convention"}}` | established patterns in this project |
|
||||
|
||||
Combine with `user_id` using AND:
|
||||
Full filter (replace `<your_user_id>` with the active user_id from your runtime):
|
||||
```python
|
||||
filters={"AND": [{"user_id": "alice"}, {"metadata.type": "decision"}]}
|
||||
filters={"AND": [{"user_id": "<your_user_id>"}, {"metadata": {"type": "decision"}}]}
|
||||
```
|
||||
|
||||
### Worked example
|
||||
@@ -67,15 +74,16 @@ search_memories(query="Refactor the auth module to use JWT")
|
||||
# Hits whatever shares words. Misses prior decisions and preferences.
|
||||
```
|
||||
|
||||
Do (parallel):
|
||||
Do (parallel — substitute the active `user_id` for `<your_user_id>`):
|
||||
```python
|
||||
search_memories(query="auth module decisions",
|
||||
filters={"AND": [{"user_id": "alice"}, {"metadata.type": "decision"}]})
|
||||
search_memories(query="JWT", filters={"user_id": "alice"})
|
||||
filters={"AND": [{"user_id": "<your_user_id>"}, {"metadata": {"type": "decision"}}]})
|
||||
search_memories(query="JWT",
|
||||
filters={"AND": [{"user_id": "<your_user_id>"}]})
|
||||
search_memories(query="auth refactor failures",
|
||||
filters={"AND": [{"user_id": "alice"}, {"metadata.type": "anti_pattern"}]})
|
||||
filters={"AND": [{"user_id": "<your_user_id>"}, {"metadata": {"type": "anti_pattern"}}]})
|
||||
search_memories(query="auth",
|
||||
filters={"AND": [{"user_id": "alice"}, {"metadata.type": "user_preference"}]})
|
||||
filters={"AND": [{"user_id": "<your_user_id>"}, {"metadata": {"type": "user_preference"}}]})
|
||||
```
|
||||
|
||||
## After completing significant work
|
||||
|
||||
Reference in New Issue
Block a user