Skip to content

fix(mem0): preserve nested filter objects in search requests - #75

Merged
yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
PoisonGodv:fix/mem0-56-structured-filters
Nov 10, 2026
Merged

yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
PoisonGodv:fix/mem0-56-structured-filters

Conversation

@PoisonGodv

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

AND/OR/NOT currently serialize their children to strings before serializing the parent, so /search receives quoted JSON instead of nested filter objects. Build maps/lists recursively and serialize once at the existing public String boundary.

Does this pull request fix one issue?

Refs #56. This addresses client encoding; complete deployed-service acceptance remains unverified.

Describe how you did it

Preserve comparison mappings, operand order, values and user/agent/run scope fields. AND/OR contain object lists; NOT contains a singleton object list, following the self-hosted OSS contract checked at Mem0 2.2.1 (94c3fe9f238f3dbf29c9ce98643bd71eb13077cd).

Compatibility change: malformed logical operands or arity now throw IllegalArgumentException instead of silently dropping conditions. Filter.Group remains unsupported and is explicitly rejected; this does not add grouped-text-expression support.

Describe how to verify it

From the repository root, with Maven 3.9.7:

mvn -B -pl memory-repository/argi-model-chat-memory-repository-mem0 -am -Dtest=Mem0FilterExpressionConverterTest,Mem0FilterHttpRequestTest test
mvn -B -pl memory-repository/argi-model-chat-memory-repository-mem0 -am test

The focused tests pass all 30 cases on both JDK 17.0.11 and JDK 21.0.13. The same test sources fail 16 of 30 cases on the unchanged base (4b542248e81bc08147c2abde114e8baf1877c0f7, JDK 21). The JDK 21 module run passes 57 tests, including those 30; these counts overlap. All passing runs have zero failures, errors or skips. The reactor already sets failIfNoSpecifiedTests=false for prerequisite modules.

Coverage includes mixed nesting, comparison/membership operators, operand order, special characters, invalid structures and actual Java HTTP request bodies with user-only, agent-only, run-only and combined scopes. HTTP tests use a loopback stub. Changed-file formatting and selected-reactor Checkstyle pass.

Special notes for reviews

A separate local contract harness exercises unchanged extracted Mem0 2.2.1 search/validation/preprocessing/Qdrant translation methods with Qdrant local mode and Java request-body replays. It does not initialize a complete Memory instance or run the REST service, authentication, embeddings, scoring, reranking or network Qdrant. The deployed Mem0 release is unknown; the repository's v1.1 setting is not a package-version pin.

Two upstream preprocessing limitations remain: contradictory same-field equality conditions inside AND collapse to the later value, and an AND containing two OR groups loses the earlier OR list. This client encoding fix resolves neither limitation and does not establish arbitrary nested-filter semantics across backends/releases. Whole-repository build/tests and CI are not claimed.

AI assistance disclosure: implementation, tests, independent local review and this PR text were prepared with AI assistance.

@yuluo-yx

Copy link
Copy Markdown
Member

lgtm

@yuluo-yx
yuluo-yx merged commit 000bef6 into agentic-ai-java:main Nov 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants