Repository navigation
feat(langgraph): support raw filter strings - #1343
Closed
haosenwang1018 wants to merge 3 commits into
Closed
haosenwang1018 wants to merge 3 commits into
haosenwang1018 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for passing raw (string) filters through the LangGraph client wrapper and core Python client methods, aligning wrapper behavior with the updated client search() / list() API.
Changes:
- Extend
Memory.search()andMemory.list()to accept a rawfilterstring and AND-combine it with existing built-in andfilter_dictfilters. - Update LangGraph
MemMachineTools.search_memory()to accept and forward the rawfilterargument. - Add/adjust unit and integration tests to cover raw filter passthrough and updated
filter_dictkey conventions (metadata.prefix).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/client/src/memmachine_client/memory.py | Adds filter parameter and combines raw + dict filters into a single request filter string. |
| packages/client/src/memmachine_client/langgraph.py | Extends tool wrapper to accept and forward filter. |
| packages/client/client_tests/test_memory.py | Adds tests for raw filter strings and updates filter_dict expectations to include metadata. prefixes. |
| packages/client/client_tests/test_langgraph.py | Adds test for raw filter passthrough and updates expected calls to include filter=None. |
| packages/client/client_tests/test_integration_complete.py | Updates integration test to use metadata.-prefixed keys in filter_dict. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
459
to
468
| def list( | ||
| self, | ||
| memory_type: MemoryType = MemoryType.Episodic, | ||
| page_size: int = 100, | ||
| page_num: int = 0, | ||
| filter_dict: dict[str, str] | None = None, | ||
| filter: str | None = None, | ||
| set_metadata: dict[str, JsonValue] | None = None, | ||
| timeout: int | None = None, | ||
| ) -> ListResult: |
Comment on lines
+418
to
+424
| dict_filter_str = self._dict_to_filter_string(merged_filters) if merged_filters else "" | ||
| explicit_filter = filter.strip() if filter else "" | ||
|
|
||
| if dict_filter_str and explicit_filter: | ||
| filter_str = f"{dict_filter_str} AND ({explicit_filter})" | ||
| else: | ||
| filter_str = dict_filter_str or explicit_filter |
| if there are key conflicts. | ||
| timeout: Request timeout in seconds (uses client default if not provided) | ||
| filter: Optional raw filter string. If provided together with built-in or | ||
| `filter_dict` filters, all filters are combined with AND. |
Comment on lines
+421
to
+424
| if dict_filter_str and explicit_filter: | ||
| filter_str = f"{dict_filter_str} AND ({explicit_filter})" | ||
| else: | ||
| filter_str = dict_filter_str or explicit_filter |
3 of 4 tasks
malatewang
added a commit
that referenced
this pull request
May 13, 2026
…ion (#1403) * feat(client+langgraph): raw filter strings and EpisodeType normalization Add three small features to the Python client and its LangGraph wrapper so callers can pass structured filter expressions and either-enum-or-string episode types directly. 1. `Memory.search(filter=...)` and `Memory.list(filter=...)` Accept an optional raw filter string alongside `filter_dict`. When both are provided, the two are combined with `AND`. The raw filter is passed through to the v2 `SearchMemoriesSpec.filter` / `ListMemoriesSpec.filter` fields unchanged. 2. `MemMachineTools.search_memory(filter=...)` Pipes the same raw filter through the LangGraph search-memory tool. 3. `MemMachineTools.add_memory(episode_type=...)` Accept either an `EpisodeType` enum or its string value (e.g. `"message"`), normalizing strings via `EpisodeType(...)` before delegating to `Memory.add`. The factory tool's return-type annotation was widened to match. The `filter` parameter shadows the Python builtin, which is the same trade-off `memmachine_common.api.SearchMemoriesSpec` already made for its `filter:` field — keeping the parameter name aligned with the API field. `# noqa: A002` is applied at the three call sites with a comment pointing at the API spec. This commit consolidates the substantive work from haosenwang1018's 9-commit stack (#1341 → #1349) into a single rebased+linted commit against current `main`. The original stack's prefix-style doc and test changes have been omitted because they have already landed on `main` via #1352 and #1311. The original commits authored by haosenwang1018: - 921b55f feat(client): support raw filter strings - e0849bb feat(langgraph): support raw filter strings - 53b489e fix(langgraph): normalize episode type strings Closes #1341, #1342, #1343, #1344, #1345, #1346, #1347, #1348, #1349 Co-authored-by: Steve Scargall <[email protected]> Signed-off-by: Steve Scargall <[email protected]> * docs(langgraph): document filter and episode type support --------- Signed-off-by: Steve Scargall <[email protected]> Co-authored-by: haosenwang1018 <[email protected]> Co-authored-by: Shu Wang <[email protected]>
Contributor
|
Closed by #1403 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of the change
Extend the LangGraph-oriented Python client wrapper so it can pass through raw filter strings, matching the new Python client
search()/list()capability.Description
Follow-up to #1310
This change updates
MemMachineTools.search_memory()inpackages/client/src/memmachine_client/langgraph.pyto accept an optional rawfilterstring in addition tofilter_dict.Behavior:
filter_dictbehavior remains unchangedfilter='metadata.category = "work"'filter_dictandfilterthrough tomemory.search(...)Also added test coverage in
packages/client/client_tests/test_langgraph.pyfor:filter=Nonememory.search(...)Type of change
How Has This Been Tested?
Test command:
cd packages/client && PYTHONPATH=/home/node/.openclaw/workspace/MemMachine/packages/client/src:/home/node/.openclaw/workspace/MemMachine/packages/common/src python -m pytest client_tests/test_langgraph.py -qChecklist
Maintainer Checklist