Skip to content

fix(openai-sdk-python): migrate to v4 Supermemory APIs - #1429

Open
Dhravya wants to merge 4 commits into
mainfrom
fix/openai-sdk-python-v4-api
Open

fix(openai-sdk-python): migrate to v4 Supermemory APIs#1429
Dhravya wants to merge 4 commits into
mainfrom
fix/openai-sdk-python-v4-api

Conversation

@Dhravya

@Dhravya Dhravya commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace deprecated search.execute with search.memories (hybrid mode) in search_memories
  • Replace memories.add with client.add in tools and middleware
  • Fix middleware container_tag param (was incorrectly container_tags)
  • Fix profile memory deduplication for string and Pydantic API items
  • Bump supermemory>=3.50 and requires-python>=3.9

Test plan

  • uv run pytest tests/test_tools.py::TestMemoryOperationsUnit

Made with Cursor

…y APIs

Replace deprecated search.execute and memories.add with search.memories
(hybrid) and client.add. Fix middleware container_tag param and dedupe
string/pydantic profile memory items.

Co-authored-by: Cursor <cursoragent@cursor.com>
@claude

claude Bot commented Aug 8, 2026

Copy link
Copy Markdown

Claude finished @Dhravya's task in 2m 33s —— View job


Reviewing PR #1429: migrate openai-sdk-python to v4 Supermemory APIs

  • Fetch and analyze PR diff
  • Review existing comments to avoid duplicates
  • Read changed files for context
  • Verify reported issues and check for additional bugs
  • Submit review findings

Summary

Reviewed the migration from v3 to v4 Supermemory APIs. Confirmed 2 issues that need to be addressed before merge:

  1. container_tags vs container_tag — The middleware was correctly fixed to use container_tag (singular), but tools.py still passes container_tags (plural) at lines 188 and 223. This inconsistency could cause API failures.

  2. include_full_docs silently ignored — The parameter is still accepted but no longer forwarded to the API, which is a breaking behavior change.

Additionally noted that the unit tests validate the current (incorrect) implementation and will need updating.

Score: 7/10 — Good migration overall, but the issues above need fixing before merge.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp d348090 Aug 08 2026, 03:00 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app d348090 Commit Preview URL

Branch Preview URL
Aug 08 2026, 03:01 AM

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview: Migrates the openai-sdk-python package from deprecated v3 Supermemory APIs to v4, updating search and add operations.

Issues found:

  • include_full_docs parameter in search_memories() is accepted but silently ignored after the migration — callers relying on this will get unexpected behavior.

The rest of the changes look solid:

  • Correct migration from search.execute to search.memories with hybrid mode
  • Proper fix of container_tagscontainer_tag in middleware (passing single value vs list)
  • Good defensive handling with getattr(response, "id", None) for potentially missing attributes
  • Utils deduplication correctly extended to handle Pydantic models alongside dicts and strings
  • Unit tests cover the new API contract

Score: 9/10

Minor issue that should be addressed before merge to avoid silent behavior change for existing callers.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 03849ce. Configure here.

Comment thread packages/openai-sdk-python/src/supermemory_openai/tools.py
Comment thread packages/openai-sdk-python/src/supermemory_openai/tools.py
…e.documents

Breaking: SupermemoryToolsConfig now takes container_tag (str) instead of
container_tags (list). search_memories maps include_full_docs to
include={"documents": ...} on client.search.memories.

Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
@Dhravya
Dhravya force-pushed the fix/openai-sdk-python-v4-api branch from 58d3aea to 03849ce Compare August 8, 2026 02:47

Dhravya commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label Main to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview: Migrates the openai-sdk-python package from deprecated v3 Supermemory APIs to v4, updating search and add operations.

Issues found:

  1. container_tags vs container_tag inconsistency (High): The middleware was correctly fixed to use container_tag (singular) at line 227, but tools.py still passes container_tags (plural) at lines 188 and 223. If the v4 API only accepts container_tag, these calls will fail or silently ignore the tenant scope.

  2. include_full_docs silently ignored (Medium): The search_memories function still accepts include_full_docs in its signature (line 172) and tool schema (lines 68-75), but the v4 client.search.memories call no longer forwards it. Callers relying on this behavior will get unexpected results.

  3. Unit tests assert incorrect behavior: The tests in test_tools.py (lines 202-205, 227) assert that container_tags is passed, which validates the current (incorrect) implementation rather than the correct v4 API contract. These tests will need updating when the code is fixed.

What looks good:

  • Correct migration from search.execute to search.memories with hybrid mode
  • Proper defensive handling with getattr(response, "id", None) for potentially missing attributes
  • Utils deduplication correctly extended to handle Pydantic models alongside dicts and strings
  • Good null-safety with response.results or []

Score: 7/10

The two issues above need to be addressed before merge — the container_tags bug could cause silent failures in production, and the include_full_docs change is a breaking behavior change for existing callers.

cursoragent and others added 2 commits August 8, 2026 02:58
…ssifiers

Align uv.lock package version, Trove classifiers, and mypy python_version
with requires-python >=3.9 for the breaking v2 release.

Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
…thon>=3.9

Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Breaking changes (v2.0) — please fold into PR description

Package bumped 1.0.4 → 2.0.0 (semver major for public config API break).

SupermemoryToolsConfig.container_tags (list) is removed. Use a single container_tag string instead. Search/add tool calls now send singular container_tag to the Supermemory v4 API.

# Before (v1)
config = {"container_tags": ["user-123"]}

# After (v2)
config = {"container_tag": "user-123"}

Also in this release:

  • include_full_docsinclude={"documents": ...} on client.search.memories
  • uv.lock, Trove classifiers, and mypy aligned with requires-python>=3.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants