Skip to content

java-client: extend LongTermMemoryService to take TagFilters as params#310

Open
lygaret wants to merge 1 commit into
redis:mainfrom
lygaret:feat/java-tagfilter-searchrequest
Open

java-client: extend LongTermMemoryService to take TagFilters as params#310
lygaret wants to merge 1 commit into
redis:mainfrom
lygaret:feat/java-tagfilter-searchrequest

Conversation

@lygaret

@lygaret lygaret commented Jun 12, 2026

Copy link
Copy Markdown

currently, namespace, userId, sessionId, topics, and entities are hard coded into the LongTermMemoryService's search request as strings (for eq),or lists-of-strings (for any).

replace them with a new TagFilter class, which mirrors the filter definitions in the server and other client just encodes the query into the JSON the server

see: agent-memory-server/agent_memory_server/models.py SearchRequest
see: agent-memory-client/agent-memory-client-js/src/models.ts SearchRequestParams


Note

Medium Risk
Changes public SearchRequest getter types to TagFilter, which can break compile-time callers that expected String or List; runtime search JSON should stay compatible for existing string/list builder usage.

Overview
Adds a TagFilter model to the Java client so long-term memory search can express the same tag operators as the server (eq, ne, any, all, startswith).

SearchRequest now stores user_id, session_id, namespace, topics, and entities as TagFilter instead of plain strings or string lists. Overloaded setters and builder methods still accept strings and List<String> and map them to TagFilter.eq / TagFilter.any, so existing call sites keep working while new code can pass richer filters (e.g. TagFilter.any("user-123", "__account__") or startsWith on namespace).

LongTermMemoryService.searchLongTermMemories stops wrapping filters in ad-hoc Map.of("eq", …) / Map.of("any", …) and serializes TagFilter directly; the default namespace fallback uses TagFilter.eq. Tests cover Jackson serialization and HTTP request bodies for the new operators.

Reviewed by Cursor Bugbot for commit 457057f. Bugbot is set up for automated code reviews on this repo. Configure here.

currently, `namespace`, `userId`, `sessionId`, `topics`, and `entities` are hard coded
into the LongTermMemoryService's search request as strings (for `eq`),or lists-of-strings (for `any`).

replace them with a new `TagFilter` class, which mirrors the filter definitions in the server and
other client just encodes the query into the JSON the server

see: agent-memory-server/agent_memory_server/models.py SearchRequest
see: agent-memory-client/agent-memory-client-js/src/models.ts SearchRequestParams
@lygaret lygaret changed the title extends LongTermMemoryService to take TagFilters as params java-client: extend LongTermMemoryService to take TagFilters as params Jun 12, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 457057f. Configure here.


public static TagFilter all(@NotNull String... values) {
return all(Arrays.asList(values));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty any/all filters rejected

Medium Severity

TagFilter.any and TagFilter.all accept empty lists (including zero-arg varargs), producing JSON such as {"any":[]}. The server TagFilter rejects empty any/all lists, so searches built this way fail validation. List-based SearchRequest helpers omit empty topic/entity lists, but the TagFilter path does not.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 457057f. Configure here.

@jit-ci

jit-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

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.

1 participant