feat(client+langgraph): raw filter strings and EpisodeType normalization - #1403
Merged
malatewang merged 3 commits intoMay 13, 2026
Merged
Conversation
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>
sscargal
force-pushed
the
rescue/1349-raw-filter-and-episode-type
branch
from
May 13, 2026 21:08
2f95f4f to
b0ad41c
Compare
malatewang
approved these changes
May 13, 2026
edwinyyyu
approved these changes
May 13, 2026
This was referenced May 13, 2026
connectsudhindra-gif
pushed a commit
to connectsudhindra-gif/MemMachine
that referenced
this pull request
Aug 15, 2026
…" string MemMachineMemory.add() called memory.add(episode_type="text", ...), but Memory.add() expects an EpisodeType enum and calls episode_type.value internally, raising AttributeError: 'str' object has no attribute 'value'. "text" was also never a valid EpisodeType value (only MESSAGE="message" exists), so this crashed on every call. Same failure mode as the LangGraph integration bug fixed in MemMachine#1403 (issue MemMachine#1002).
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.
Summary
Rescues the substantive work from @haosenwang1018's 9-commit stack (#1341 → #1349) by cherry-picking the 3 commits that contain real feature code onto a fresh branch from current
main, with lint and type fixes applied. The prefix-style doc and test commits in the original stack are not included here becausemainalready absorbed them via #1352 and #1311.This PR adds:
Memory.search(filter=...)andMemory.list(filter=...)— accept an optional raw filter string alongsidefilter_dict. When both are provided they are combined withAND. The raw filter passes through to the v2SearchMemoriesSpec.filter/ListMemoriesSpec.filterAPI fields unchanged.MemMachineTools.search_memory(filter=...)— pipes the raw filter through the LangGraph search-memory tool wrapper.MemMachineTools.add_memory(episode_type=...)— accepts either anEpisodeTypeenum or its string value (e.g."message"), normalizing strings viaEpisodeType(...)before delegating toMemory.add. The factory tool's return-type annotation was widened to match.Tests for all three additions are included.
Original commits (preserved as the squash commit author)
921b55f2feat(client): support raw filter strings (@haosenwang1018)e0849bb1feat(langgraph): support raw filter strings (@haosenwang1018)53b489e5fix(langgraph): normalize episode type strings (@haosenwang1018)Changes vs. originals
langgraph.pydocstring (merged main's updatedfilter_dictprefix wording with the newfilterparameter doc).# noqa: A002at threefilter:parameter sites with a comment pointing at the matchingSearchMemoriesSpec.filter/ListMemoriesSpec.filterAPI field name. Same trade-off the API spec already makes.create_add_memory_tool'sCallable[...]return-type annotation to include the newEpisodeType | str | Noneparameter introduced by53b489e5.Test plan
uv run ruff check packages/client/— cleanuv run ty check packages/client/— cleanuv run pytest packages/client/client_tests/test_memory.py packages/client/client_tests/test_langgraph.py— 151 passedCloses
Closes #1341, #1342, #1343, #1344, #1345, #1346, #1347, #1348, #1349
Co-authored-by: Steve Scargall steve.scargall@gmail.com