docs(langgraph): document filter and episode type support - #1349
docs(langgraph): document filter and episode type support#1349haosenwang1018 wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Python client + LangGraph wrapper to support passing a raw filter expression string and to accept episode_type as either an enum or string, and refreshes docs/examples to match.
Changes:
- Add
filter: str | Nonesupport toMemory.search()andMemory.list()by AND-combining it with existingfilter_dict/built-in metadata filters. - Normalize
episode_typestrings in LangGraph tools before calling the underlying client. - Update unit/integration tests and docs/examples to use metadata-prefixed filters and the typed
SearchResultAPI.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/client/src/memmachine_client/memory.py | Adds raw filter string support and combines it with existing filters. |
| packages/client/src/memmachine_client/langgraph.py | Adds filter passthrough and episode_type string-to-enum normalization. |
| packages/client/client_tests/test_memory.py | Adds coverage for raw filter strings and updates filter_dict expectations. |
| packages/client/client_tests/test_langgraph.py | Adds tests for raw filter passthrough and episode_type normalization; updates call expectations. |
| packages/client/client_tests/test_integration_complete.py | Updates integration test to use metadata.* keys in filter_dict. |
| packages/client/README.md | Updates example usage to typed SearchResult and metadata-prefixed filters. |
| integrations/langgraph/README.md | Documents raw filter + episode_type support and updates node example. |
| examples/memmachine_client_demo.py | Updates demo to use typed results and metadata-prefixed filter examples. |
| examples/README.md | Updates description to reflect typed API and filter examples. |
| docs/api_reference/python/client.mdx | Updates API docs example to use typed SearchResult accessors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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: |
There was a problem hiding this comment.
Adding filter as a positional parameter in the middle of list() is a backwards-incompatible change for any callers passing set_metadata/timeout positionally (their arguments will shift into filter). To keep backward compatibility, move filter to be keyword-only and/or place it after the existing positional parameters; e.g., keep set_metadata and timeout in their prior positions and add *, filter: str | None = None after them (or introduce * before filter).
| normalized_episode_type = ( | ||
| EpisodeType(episode_type) | ||
| if isinstance(episode_type, str) | ||
| else episode_type | ||
| ) |
There was a problem hiding this comment.
The current "string normalization" only converts exact string values and does not normalize common user input (e.g., leading/trailing whitespace or case differences). This can cause unexpected failures (ValueError from Enum construction) for inputs like ' message ' or 'MESSAGE'. Consider applying basic normalization (e.g., strip() and a consistent casing strategy) before constructing EpisodeType, and raise a clearer error if the value is invalid.
| The generated tools support: | ||
| - raw search filter strings via `filter='metadata.category = "work"'` | ||
| - `episode_type` as either an `EpisodeType` enum or a string value like `"message"` |
There was a problem hiding this comment.
The PR title/description frames this as aligning documentation, but this PR also introduces behavior/API surface changes in the Python client and LangGraph wrapper (e.g., new filter parameter, episode_type handling) plus tests. Please update the PR title/description to explicitly mention the client/wrapper code changes (or split docs-only vs behavior changes) so reviewers and release notes accurately reflect the scope.
|
Hi @haosenwang1018! For this PR (and all your other PRs) to merge, we need you to sign your commits. Also, please review the feedback CoPilot has generated and respond accordingly. Conflicts are especially important to respond to. Kind Regards, |
sscargal
left a comment
There was a problem hiding this comment.
@haosenwang1018 The code changes look good. Please sign your commit(s), squash them if necessary, and resolve the merge conflict. Thanks.
…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 <steve.scargall@gmail.com> Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com> * docs(langgraph): document filter and episode type support --------- Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com> Co-authored-by: haosenwang1018 <haosenwang1018@users.noreply.github.com> Co-authored-by: Shu Wang <33640803+malatewang@users.noreply.github.com>
|
Closed by #1403 |
Purpose of the change
Keep the LangGraph integration README aligned with the current wrapper capabilities.
Description
Follow-up to #1310 and #1002
This updates
integrations/langgraph/README.mdto document the wrapper features that were recently added/fixed:filter='metadata.category = "work"'episode_typestring normalization support (for exampleepisode_type="message")It also updates the example LangGraph node snippet to show both capabilities in context.
Type of change
How Has This Been Tested?
Manual verification:
filterstring supportepisode_typestring supportfilter=andepisode_type=usageChecklist
Maintainer Checklist