Skip to content

feat(sdk-playground): reflect SDK-owned memory block in debug view - #1533

Open
Dhravya wants to merge 2 commits into
sdk-dedup/pythonfrom
sdk-dedup/playground
Open

feat(sdk-playground): reflect SDK-owned memory block in debug view#1533
Dhravya wants to merge 2 commits into
sdk-dedup/pythonfrom
sdk-dedup/playground

Conversation

@Dhravya

@Dhravya Dhravya commented Aug 18, 2026

Copy link
Copy Markdown
Member

Stack Context

Part 3 (top) of a 3-PR stack moving memory deduplication into the SDKs. See sdk-dedup/tools-ts for full context.

What?

Update the SDK playground so its debug view reflects the SDK-owned memory block.

  • Displays the current deduplicated <supermemory> replacement block produced by the SDK middleware, instead of the old browser-side "seen facts" delta.
  • Adds a memory-dedupe helper and ignores local *.tsbuildinfo.

Why?

The previous debug cards were misleading — they showed an incremental browser-filtered delta while the middleware actually re-injected the full profile. Now the visualization matches what the SDK really sends.

🤖 Generated with Claude Code


Note

Low Risk
Playground-only visualization and chat gating changes; no production SDK or API behavior.

Overview
The playground debug trace now shows the deduplicated memory block the SDK middleware would inject (static → dynamic → search, mode-aware), instead of a misleading browser-side “new facts” delta. A new memory-dedupe helper mirrors @supermemory/tools middleware behavior and is applied when fetching container context and building middleware memory debug entries; the context preview card is relabeled to reflect that each turn replaces the prior <supermemory> block.

Chat UX: messaging is enabled when API keys are configured on the server (hasSupermemoryKey / hasOpenAiKey from /api/chat), not only when keys are typed in the panel. The message input stays editable while waiting for text; Send still requires non-empty input.

Also ignores *.tsbuildinfo in .gitignore.

Reviewed by Cursor Bugbot for commit ed15364. Bugbot is set up for automated code reviews on this repo. Configure here.

@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

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


Review Complete

  • Fetch PR diff and existing review comments
  • Analyze changed files for bugs, security issues, and logic errors
  • Review memory deduplication implementation
  • Submit review summary

Overview: Updates the SDK playground debug view to show the actual deduplicated memory block the SDK middleware injects, replacing the old misleading browser-side delta visualization.

Issues found: None — this looks good to ship.

Re: Cursor Bugbot's "double dedupe" concern: This is a false positive. The two code paths are separate:

  • fetchContainerContext calls fetchProfileContext → returns raw profile data (no deduplication) for UI display
  • buildMiddlewareMemoryDebug calls fetchProfileContext directly → then reconstructSdkMemoryBlock → deduplication happens once with the correct memoryMode

The implementation is correct:

  • deduplicateMemoriesForMode correctly handles mode-aware deduplication (static → dynamic → search priority)
  • Python reconstruct_python_sdk_memory_block mirrors the TypeScript logic, properly clearing static/dynamic for "query" mode
  • The flavor parameter correctly distinguishes AI SDK vs OpenAI prompt formatting
  • Both TS and Python now use include: ["static", "dynamic"] for consistent profile fetching

Score: 10/10


Dhravya commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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: Adds a memory deduplication helper and updates the SDK playground debug view to show the actual deduplicated memory block that the SDK middleware sends.

Issues found: None — this looks good to ship.

The implementation is clean:

  • dedupeProfileForMode correctly implements static → dynamic → search priority deduplication with case-insensitive normalization
  • The chatReady logic properly allows chat when either user-entered keys OR server env keys are present
  • The debug view now accurately reflects what the SDK middleware actually injects

Score: 10/10

@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 default effort and found 1 potential issue.

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 ed15364. Configure here.

dynamic: profileRaw?.dynamic ?? [],
searchResults: normalizeSearchResults(profileResponse.searchResults),
},
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong-mode double dedupe

Medium Severity

fetchContainerContext always runs dedupeProfileForMode with "full" or "profile" based only on whether a query string is present, then buildMiddlewareMemoryDebug dedupes again with the real memoryMode. For "query" mode that first pass treats overlapping search hits as profile duplicates and drops them, so the debug preview no longer matches what the SDK middleware injects.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ed15364. Configure here.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 18, 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 5d1f557 Aug 24 2026, 06:11 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 18, 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 5d1f557 Commit Preview URL

Branch Preview URL
Aug 24 2026, 06:13 PM

@ved015
ved015 force-pushed the sdk-dedup/playground branch from ed15364 to 5243a43 Compare August 24, 2026 16:21

@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: Adds a dedupeProfileForMode helper to the SDK playground and updates the debug view to show the actual deduplicated memory block the SDK middleware sends.

Issues found: None — this looks good to ship.

Re: Cursor Bugbot's "double dedupe" concern: This is a false positive. The two call sites are in separate code paths:

  • fetchContainerContext is used by the /api/context endpoint for UI display
  • buildMiddlewareMemoryDebug calls fetchProfileContext directly (line 236-241), not fetchContainerContext, so it gets fresh raw data and dedupes once with the correct memoryMode

The implementation is correct:

  • dedupeProfileForMode correctly implements static → dynamic → search priority deduplication
  • normalizeFactKey properly normalizes text by stripping date/recent prefixes and normalizing whitespace
  • Mode handling is accurate: "query" keeps only search results, "profile" clears search results, "full" keeps all

Score: 10/10

@ved015
ved015 force-pushed the sdk-dedup/playground branch from 5243a43 to 2d03036 Compare August 24, 2026 17:08
Dhravya and others added 2 commits August 24, 2026 23:38
Update the playground to display the current deduplicated <supermemory>
replacement block produced by the SDK middleware instead of a browser-side
seen-facts delta. Add memory-dedupe helper and ignore local tsbuildinfo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ved015
ved015 force-pushed the sdk-dedup/playground branch from a46eba5 to 5d1f557 Compare August 24, 2026 18:09
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