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 @ved015's task in 2m 29s —— View job


Reviewing PR #1429

  • Fetch PR diff and existing review comments
  • Review code changes for bugs and security issues
  • Check if previous review findings have been addressed
  • Post review summary

Overview: Migrates the openai-sdk-python package from deprecated v3 Supermemory APIs to v4, updating search.executesearch.memories (hybrid mode) and memories.addclient.add.

Previous review findings status:

  1. include_full_docs silently ignored — FIXED in commit 183e9fb

    • Parameter changed to Optional[bool] with deprecation warning (tools.py:180-186)
    • Removed from OpenAI tool schema (no longer exposed to models)
    • Test added to verify deprecation warning is raised
  2. search.memories using container_tags (plural) — FIXED in commit 183e9fb

    • Changed to container_tag=self.container_tags[0] at tools.py:191
    • Test updated to verify singular parameter is used
  3. client.add using container_tags (plural) — Appears intentional

    • The docstring (tools.py:25-28) explicitly states: "The first container tag is the primary v4 search scope; all configured tags are applied when adding a memory"
    • Test validates this behavior (test_tools.py:206-209)
    • Middleware uses container_tag (singular) for single-user scenarios, while tools module uses container_tags (plural) for multi-container scenarios
    • This is a valid design pattern if the SDK supports both parameters

Issues found: None — the meaningful issues from previous reviews have been addressed in the hardening commit.

Score: 9/10

The v4 migration looks clean. The deprecation warning for include_full_docs is a good migration path for existing callers. The only minor note is the container_tag vs container_tags difference between middleware and tools, but this appears intentional per the docstring — tools support multi-container writes while middleware targets single-container scenarios.


| Branch: fix/openai-sdk-python-v4-api

@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 7eca7c7 Aug 21 2026, 03:56 PM

@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 7eca7c7 Commit Preview URL

Branch Preview URL
Aug 21 2026, 03:58 PM

@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
@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

@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.

@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

@socket-security

socket-security Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​supermemory@​3.4.0 ⏵ 3.56.0100 +1100100 +1100100

View full report

Resolve pyproject.toml conflict by keeping supermemory>=3.50.0
(required for v4 API migration) and main's package version 1.0.5.

Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
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.

3 participants