Skip to content

feat(sdk-playground): interactive SDK chat playground - #1437

Open
Dhravya wants to merge 3 commits into
graphite-base/1437from
feat/sdk-playground
Open

feat(sdk-playground): interactive SDK chat playground#1437
Dhravya wants to merge 3 commits into
graphite-base/1437from
feat/sdk-playground

Conversation

@Dhravya

@Dhravya Dhravya commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Add apps/sdk-playground — chat UI to test TS/Python SDK integrations
  • Context panel with document memories, API keys in dashboard, tools reference tab
  • Python FastAPI server on port 8792; portless entry in portless.json

Stacked on #1436

Test plan

  • cd apps/sdk-playground && bun run check-types
  • bun run dev with Supermemory + OpenAI keys in UI
  • Switch SDKs and verify chat + context panel

Made with Cursor

@claude

claude Bot commented Aug 8, 2026

Copy link
Copy Markdown

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


Code Review Complete

  • Fetch PR diff and existing review comments
  • Analyze code changes for bugs, security issues, and logic errors
  • Check critical files in detail
  • Submit review findings

Overview: Adds an SDK playground app with Next.js frontend and Python FastAPI backend for interactively testing Supermemory SDK integrations across TypeScript and Python.

Issues found: None — this looks good to ship.

I reviewed ~5700 lines of new code across 29 files including:

  • Next.js API routes (/api/chat, /api/context) with proper request validation
  • Python FastAPI server with multiple SDK integration handlers
  • Frontend components (chat UI, API keys panel, context panel)
  • Core business logic (chat-handlers.ts, context-api.ts, request-validation.ts)
  • CI workflow additions for Python validation

Previous review issues addressed:

The latest commits fix the issues from the earlier Cursor Bugbot review:

  • Context API no longer requires OpenAI key — now uses resolveSupermemoryApiKey at api/context/route.ts:2,20-21 instead of resolveApiKeys
  • No more env-var race condition — The withPlaygroundEnvKeys function that temporarily overwrote environment variables has been removed entirely. API keys are now passed directly to SDK clients via the keys: PlaygroundApiKeys parameter

Security measures in place:

  • TrustedHostMiddleware restricts Python server to localhost only (server.py:359-362)
  • assertTrustedBrowserRequest validates request origin and rejects cross-site requests (request-validation.ts:75-96)
  • mayUseEnvironmentKeys restricts env-key usage to trusted hosts — localhost and sdk.dev.supermemory.ai (request-validation.ts:99-112)
  • Comprehensive input validation with length limits, pattern matching, and body size checks
  • SecretStr used for API keys in Python Pydantic models (server.py:380-384)
  • API keys stored in sessionStorage (not localStorage), scoped to tab lifetime (api-keys.ts:47,61)

Design choices appropriate for a dev playground:

  • 8-step tool loop limit prevents runaway execution (chat-handlers.ts:297, server.py:559)
  • Proper timeout handling with best-effort debug info collection (chat-handlers.ts:62-115)
  • Port configuration is consistent throughout (8792)

Score: 9/10

Minor deduction: The debug memory panel explicitly notes it shows a "post-response snapshot" rather than the exact context injected by middleware — this is working as designed and clearly labeled, not a bug.


@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 8a78b11 Aug 24 2026, 04:26 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 8a78b11 Commit Preview URL

Branch Preview URL
Aug 24 2026, 04:28 PM

@socket-security

socket-security Bot commented Aug 8, 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
Addedpypi/​openai@​2.53.090100100100100
Addednpm/​concurrently@​9.2.49910010093100
Addedpypi/​uvicorn@​0.52.198100100100100
Addedpypi/​python-dotenv@​1.2.299100100100100
Addedpypi/​requests@​2.34.299100100100100
Addedpypi/​supermemory@​3.56.0100100100100100
Addedpypi/​fastapi@​0.141.1100100100100100

View full report

@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 3 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 93f92cd. Configure here.

},
{ status: 400 },
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Context API needs OpenAI key

Medium Severity

The context routes use resolveApiKeys, which returns null unless both Supermemory and OpenAI keys are present. Loading container context only calls Supermemory, and the context panel only validates the Supermemory key, so a dashboard with just a Supermemory key still gets a 400 from /api/context.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93f92cd. Configure here.

Comment thread apps/sdk-playground/src/lib/api-keys.ts Outdated
} else {
delete process.env.OPENAI_API_KEY
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shared env keys race

Medium Severity

Chat handlers temporarily overwrite global SUPERMEMORY_API_KEY and OPENAI_API_KEY on the shared Node process and Python process. Overlapping requests with different dashboard keys can read or write the wrong credentials mid-flight.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93f92cd. Configure here.

skipMemoryOnError: middlewareConfig.skipMemoryOnError,
},
keys.supermemoryApiKey,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Debug shows post-chat profile

Low Severity

Middleware memory debug is built by fetching profile after the model response (and after auto-save). The “Context injected into prompt” preview can include memories written in that same turn, not what middleware actually injected.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93f92cd. Configure here.

@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 new SDK playground app with Next.js frontend and Python FastAPI backend for interactively testing Supermemory SDK integrations across TypeScript and Python.

Issues found: None — this looks good to ship.

I reviewed ~4000 lines of new code across 26 files including:

  • Next.js API routes (/api/chat, /api/context)
  • Python FastAPI server with multiple SDK integration handlers
  • Frontend components (chat UI, API keys panel, context panel)
  • Core business logic (chat-handlers.ts, context-api.ts, api-keys.ts)

Design choices appropriate for a dev playground:

  • API keys in localStorage with clear user messaging
  • Permissive CORS on Python server (allow_origins=["*"])
  • Temporary env var manipulation for SDK compatibility

Code quality observations:

  • Good error handling throughout both TypeScript and Python
  • Proper API key resolution chain (user input → env vars)
  • Clean SDK abstraction via registry pattern
  • Tool loop limits prevent runaway execution (8 steps max)

Score: 9/10

Minor deduction for documentation mismatch (README says port 8791, env example says 8792) — not a blocker.

Dhravya commented Aug 8, 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.

Dhravya and others added 2 commits August 24, 2026 20:01
Next.js UI with TypeScript and Python chat backends, context panel,
API key management, tools reference, and middleware configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ved015
ved015 force-pushed the graphite-base/1437 branch from 78269ff to 69def1a Compare August 24, 2026 14:43
@ved015
ved015 force-pushed the feat/sdk-playground branch from 93f92cd to 4e04a0d Compare August 24, 2026 14:43

@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 an SDK playground app with Next.js frontend and Python FastAPI backend for interactively testing Supermemory SDK integrations across TypeScript and Python.

Issues found: None — this looks good to ship.

I reviewed ~5000 lines of new code across 29 files including:

  • Next.js API routes (/api/chat, /api/context) with proper request validation
  • Python FastAPI server with multiple SDK integration handlers
  • Frontend components (chat UI, API keys panel, context panel)
  • Core business logic (chat-handlers.ts, context-api.ts, request-validation.ts)
  • CI workflow additions for Python validation

Previous review issues addressed:
The latest commit (4e04a0d) fixes the two substantive issues from the earlier Cursor Bugbot review:

  • ✅ Context API no longer requires OpenAI key (now uses resolveSupermemoryApiKey)
  • ✅ API keys are passed directly to SDK clients, eliminating the env-var race condition

Security measures in place:

  • TrustedHostMiddleware restricts Python server to localhost only
  • assertTrustedBrowserRequest validates request origin and rejects cross-site requests
  • mayUseEnvironmentKeys restricts env-key usage to trusted hosts (localhost, sdk.dev.supermemory.ai)
  • Comprehensive input validation with length limits, pattern matching, and body size checks
  • SecretStr used for API keys in Python Pydantic models
  • API keys stored in sessionStorage (not localStorage), scoped to tab lifetime

Design choices appropriate for a dev playground:

  • Permissive CORS on Python server (localhost-only anyway)
  • 8-step tool loop limit prevents runaway execution
  • Proper timeout handling with best-effort debug info collection

Score: 9/10

Minor deduction for documentation mismatch (README mentions port 8791 in one place, env example says 8792) — not a blocker.

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