Conversation
…ssages `utils.py` in cartesia-sdk-python and pipecat-sdk-python are copies of the same file. supermemoryai#1434 hardened two spots in the pipecat copy and missed cartesia. `unique_search` calls `_field(r, ...)` on every search result. For a plain string that finds no attribute, falls back to `""`, and the entry is dropped before it reaches the prompt. `format_memories_to_text` in the same file has an `isinstance(item, str)` branch for search results, so that branch is currently unreachable. `get_last_user_message` indexed `msg["role"]` and `msg["content"]` positionally, so a tool-call turn or provider event missing either key raised KeyError instead of being skipped, and non-string content was returned verbatim despite the `str | None` annotation. Both hunks now match the pipecat implementation.
|
Two things a reviewer would reasonably want to know, both checked: Do the other SDKs have the same two bugs? No. Is the rest of the file in sync with pipecat now? Yes. The two One thing that audit did turn up, which is not fixed here: both voice SDKs diverge from the TypeScript |
Summary
src/supermemory_cartesia/utils.pyandsrc/supermemory_pipecat/utils.pyare copies of the same file. #1434 hardened two spots in the pipecat copy and missed the cartesia one. This brings the two hunks back to parity and adds regression tests.Bug 1 — plain-string search results are silently dropped
deduplicate_memories→unique_searchcalls_field(r, "memory", "chunk", "content", default="")on every result. For a plainstrthat finds no attribute, falls back to"", and the entry never reaches the prompt.format_memories_to_textin the same file already has anisinstance(item, str)branch for search results, so that branch is currently unreachable — nothing can get past dedup as a string.Reproduced against the pipecat copy as the reference:
Bug 2 —
get_last_user_messageraisesKeyErrorIt indexed
msg["role"]andmsg["content"]positionally, so a tool-call turn or provider event missing either key raised instead of being skipped. Non-string content was also returned verbatim despite the-> str | Noneannotation.Changes
src/supermemory_cartesia/utils.py— both hunks now match the pipecat implementation exactly.tests/test_utils.py— new, 6 tests.Test plan
mainand pass with the fix:8 passed.ci-python.ymlalready path-filterspackages/cartesia-sdk-python/**, so these run in CI with no workflow change.No behaviour change for dict or Stainless-model search results — covered by
test_still_reads_the_memory_field_of_models_and_dicts.