Commit graph

18 commits

Author SHA1 Message Date
Dhravya
03773c4f2e
feat(python-sdks): SDK-level cross-source memory deduplication (#1532)
## Stack Context

Part 2 of a 3-PR stack moving memory deduplication into the SDKs. See `sdk-dedup/tools-ts` (parent) for the full context and the TypeScript implementation this mirrors.

## What?

Port the normalized, priority-ordered (`static > dynamic > search`) profile deduplication into the Python SDKs.

- Each request injects one **owned memory block that replaces** the prior block rather than accumulating.
- Dedup is **request-local** (no shared state), so it stays correct under concurrency.

Covers OpenAI, Agent Framework (middleware + context provider), Cartesia, and Pipecat.

## Why?

Keeps the Python SDKs at behavioral parity with the TypeScript SDK so all integrations deduplicate memory the same way.

## Testing

- OpenAI: 31 passed, 11 skipped (live)
- Agent Framework: 59 passed
- Cartesia: 8 passed
- Pipecat: 8 passed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes memory formatting and system-prompt injection across multiple SDK integrations; incorrect dedup or replacement could alter LLM context, but there is no auth or data-store risk.
>
> **Overview**
> Ports **normalized cross-source memory deduplication** and **replace-not-append injection** into the Python OpenAI, Agent Framework, Cartesia, and Pipecat packages so they match the TypeScript SDK behavior.
>
> **Deduplication** uses request-local keys: strip optional `[YYYY-MM-DD]` prefixes, normalize whitespace, and compare with `casefold`, with priority **static → dynamic → search**. In **`query` mode**, profile static/dynamic are excluded from dedup input so facts that only appear in search (or overlap profile) are not dropped before formatting.
>
> **Injection** no longer appends memory text every turn. OpenAI and Agent Framework middleware **strip prior owned `<supermemory context="user-memories" readonly>` blocks** and **replace** them once per request while keeping the caller’s system instructions; extra system messages lose stale blocks only. New helpers (`strip`/`replace`/`wrap`) live in each package’s utils.
>
> Tests cover normalized fact variants, query-mode search retention, and stale block replacement.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 42f308b224. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-09-01 06:10:36 +00:00
Dhravya
c262cc9953
fix(python-sdks): v4 API migration for integration packages (#1434)
## Summary
- **agent-framework**: proactive search tool descriptions
- **cartesia / pipecat**: v4 `client.add` + hybrid search, dedupe fixes, tests

Stacked on #1433

## Test plan
- [ ] pytest in agent-framework, cartesia, pipecat packages

Made with [Cursor](https://cursor.com)
2026-09-01 06:10:36 +00:00
Dhravya
348483d5e8
feat(openai-sdk-python): 7-tool parity (#1430)
## Summary
- Expand `SupermemoryTools` from 2 tools to 7 (matches `@supermemory/tools`)
- Add `memory_forget` via shared HTTP helper
- Add document list/add/delete and get_profile tool surfaces
- Expand tests for new tools and execution paths

Stacked on #1429

## Test plan
- [x] `uv run pytest tests/test_tools.py::TestMemoryOperationsUnit`

Made with [Cursor](https://cursor.com)
2026-09-01 04:34:18 +00:00
Dhravya
c5b7e7d4fc
fix(openai-sdk-python): migrate to v4 Supermemory APIs (#1429)
## 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
- [x] `uv run pytest tests/test_tools.py::TestMemoryOperationsUnit`

Made with [Cursor](https://cursor.com)
2026-09-01 04:34:18 +00:00
pawan
47152afc1d
fix(openai-sdk): cap supermemory to <3.5 so a fresh install imports (#1236) 2026-08-12 20:56:54 +05:30
icyzh
f833843760
fix(openai-sdk): use AsyncSupermemory and correct client API calls (#1063) 2026-06-17 09:05:11 -07:00
nyxst4ck
6a4e0b2514
docs: quote pip extras install examples (#1039)
Co-authored-by: nyxst4ck <289980115+nyxst4ck@users.noreply.github.com>
2026-06-16 23:30:41 -07:00
devteamaegis
55445bff1d
fix(openai-sdk): don't inject empty system prompt when no memories are found (#999)
Co-authored-by: Ishaan Samantray <ishaansamantray@Ishaans-MacBook-Pro.local>
2026-05-26 22:28:35 +05:30
sreedharsreeram
0104a2572c update open ai python sdk (#879) 2026-04-25 01:43:14 +00:00
Ishaan Gupta
a0e3d7d192
perf(middleware): await background task cancellation on timeout (#786) 2026-04-12 14:22:41 -07:00
Dhravya Shah
87b361c26b
docs changes (#678)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 16:55:32 -08:00
nexxeln
10d8f92439 fix deduplication in python sdk (#626)
done in a similar way to the ai sdk
2025-12-29 18:51:43 +00:00
nexxeln
ea9bf13d31 add openai middleware functionality for python sdk (#546)
add openai middleware functionality

fix critical type errors and linting issues

update readme with middleware documentation
2025-11-11 02:16:34 +00:00
Shreyans Jain
4467b65524
fix: openai python sdk package export (#432) 2025-10-08 15:54:42 -07:00
Dhravya Shah
4d6fd37c99 fix: model names 2025-10-03 02:41:49 -07:00
CodeWithShreyans
101f3817bd
feat: openai python sdk (#409) 2025-09-03 21:48:36 +00:00
CodeWithShreyans
cae7051d1a
feat: new tools package (#407) 2025-09-02 23:11:19 +00:00
CodeWithShreyans
3a0e264b7e
feat: openai js and python sdk utilities (#389)
needs testing
2025-08-27 23:34:49 +00:00