fix: crash when profile search returns hits (Cartesia + Pipecat) - #1615
Open
noQbot wants to merge 1 commit into
Open
fix: crash when profile search returns hits (Cartesia + Pipecat)#1615noQbot wants to merge 1 commit into
noQbot wants to merge 1 commit into
Conversation
deduplicate_memories() called `r.get("memory")` on each search result, but
the Supermemory SDK returns `response.search_results.results` as Pydantic
model objects, not dicts. Models have no `.get()`, so every non-empty search
raised AttributeError on the default mode="full" path; empty search skipped
the loop and hid the bug. Existing tests only passed dict fixtures, so they
stayed green.
Normalize each result to a dict via model_dump(by_alias=True) before reading
it (mirroring the openai-sdk-python package, which already model_dump()s the
same results), and pass real dicts through unchanged. Add regression tests
that feed dict-less model stand-ins through the dedup + formatting path.
Co-Authored-By: Vinv-AI <309466812+Vinv-AI@users.noreply.github.com>
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.
What & why
deduplicate_memories()in both the Cartesia and Pipecat integrations callsr.get("memory")on each search result:But the callers pass
response.search_results.resultsstraight from the SDK (agent.py/service.py), and the Supermemory SDK returns those as Pydantic model objects, not dicts. Models have no.get(), so any non-empty profile search raisesAttributeError— on the defaultmode="full"path. An empty search skips the loop, which is why it only crashes once memories actually exist.This isn't hypothetical for the SDK shape: the sibling
openai-sdk-pythonpackage already doesresults=[r.model_dump() for r in response.results]— you only call.model_dump()on models — so the model shape is established repo behavior. The Cartesia/Pipecat packages just skipped that conversion.Why existing tests didn't catch it: the current fixtures pass dicts (
{"memory": "..."}), so they exercise a shape production never sends.The fix
Normalize each result to a dict via
model_dump(by_alias=True)before reading it (keeping API field names likeupdatedAtso the temporal context still renders), and pass real dicts through unchanged:Applied identically to
packages/cartesia-sdk-pythonandpackages/pipecat-sdk-python.Tests
Added
tests/test_search_result_models.pyto both packages, feeding dict-less model stand-ins through the dedup + formatting path (asserts no crash, correct dedup,updatedAtrenders, and that dict inputs still work).Compatibility
Backward compatible — dict inputs behave exactly as before. No API or behavior change for callers already passing dicts.