fix(n8n): restore App ID, Includes and Excludes, add App ID filters

Reverts the removal in 2a61fe1a. That commit dropped app_id, includes and
excludes from Add because docs/openapi.json does not declare them on
POST /v3/memories/add/. The schema is incomplete: probing the live endpoint
shows all three are accepted and honoured.

- app_id is persisted and is queryable via /v3/memories/search/ and
  /v3/memories/, so the entity-id guard accepts it again as a valid scope
- includes/excludes demonstrably steer extraction. The same message stored
  three memories unfiltered and one under
  includes: "only record food and diet preferences"

Search and Get Many gain an App ID filter alongside User/Agent/Run. Writing
an app-scoped memory was otherwise unreadable from this node, and app_id is
how the OpenCode and Pi Agent plugins express project scope.

buildEntityFilters now takes the ids as an object rather than four adjacent
positional strings, so a fifth entity is a one-key change.
This commit is contained in:
kartik-mem0
2026-07-29 22:18:19 +05:30
parent a8e2a49209
commit 29601e54f4
4 changed files with 120 additions and 26 deletions
+3 -3
View File
@@ -34,11 +34,11 @@ Two independent controls:
- **Wait for Completion** (on by default) decides whether the node polls. Turn it off to return immediately with the event ID.
- **Infer** (on by default, under Additional Fields) decides whether the API runs LLM extraction at all. Turn it off to store the messages verbatim.
**Custom Instructions** and **Custom Categories** (also under Additional Fields) steer what extraction keeps for that call.
**Custom Instructions**, **Custom Categories**, **Includes**, and **Excludes** (also under Additional Fields) steer what extraction keeps for that call. **Agent ID**, **App ID**, and **Run ID** live there too, and scope the memory alongside (or instead of) **User ID**.
### Entity filters on Search & Get Many
Both take **User ID**, **Agent ID**, and **Run ID**, and at least one is required — the API rejects a query with no entity scope, and the node fails with a clear message before calling it.
Both take **User ID**, **Agent ID**, **App ID**, and **Run ID**, and at least one is required — the API rejects a query with no entity scope, and the node fails with a clear message before calling it.
Supplying several combines them with **OR**, giving the union of those scopes. Mem0 indexes each entity separately, so an `AND` across `user_id` and `agent_id` matches nothing even for a memory written with both. To narrow instead of widen, run one operation per entity id.
@@ -52,7 +52,7 @@ This node is also **usable as a tool** by n8n's AI Agent node — attach it so a
A typical loop:
1. **Search** memory before answering, filtered by `User ID` (or `Agent ID` / `Run ID`).
1. **Search** memory before answering, filtered by `User ID` (or `Agent ID` / `App ID` / `Run ID`).
2. **Add** durable facts after a meaningful exchange.
Memory writes are asynchronous by default; allow a moment after an Add before searching for the same content.