Skip to content

feat(ai-sandbox-vercel): tag sandbox API requests with a framework user-agent#921

Open
marc-vercel wants to merge 4 commits into
TanStack:mainfrom
marc-vercel:marc-vercel/sandbox-vercel-user-agent
Open

feat(ai-sandbox-vercel): tag sandbox API requests with a framework user-agent#921
marc-vercel wants to merge 4 commits into
TanStack:mainfrom
marc-vercel:marc-vercel/sandbox-vercel-user-agent

Conversation

@marc-vercel

@marc-vercel marc-vercel commented Jul 9, 2026

Copy link
Copy Markdown

🎯 Changes

On the Vercel side, we would like to be able to distinguish the requests that come from @tanstack/ai.

This PR adds the package name @tanstack/ai as a token in the User-Agent HTTP header for all Vercel Sandbox API requests (create, resume, destroy). Existing user-agent values are preserved and the token is appended rather than replacing them. We have already done something similar with the Eve framework: vercel/eve#332.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

Testing notes: unit tests were added in packages/ai-sandbox-vercel/tests/user-agent.test.ts covering token appending/defaulting, header/field preservation, Request input handling, and fallback fetch.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Vercel Sandbox requests now include an added @tanstack/ai token in the user-agent header.
    • Existing user-agent values are preserved and updated rather than replaced.
  • Tests

    • Added coverage for header handling, request forwarding, and default fetch behavior.

…er-agent

Wrap the Vercel Sandbox SDK's fetch so every control-plane request appends a
`@tanstack/ai-sandbox-vercel` token to the user-agent, letting Vercel attribute
sandbox traffic to this framework. Mirrors vercel/eve#332.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a withSandboxUserAgent fetch wrapper in the Vercel sandbox package that appends an @tanstack/ai token to the user-agent header. VercelProvider now uses this wrapped fetch in Sandbox.create, resume, and destroy. Includes tests and a changeset.

Changes

Vercel sandbox user-agent tagging

Layer / File(s) Summary
User-agent fetch wrapper
packages/ai-sandbox-vercel/src/user-agent.ts
Adds USER_AGENT_TOKEN constant and withSandboxUserAgent function that wraps fetch to set or append the token to the user-agent header, forwarding to an inner fetch or globalThis.fetch.
Provider wiring
packages/ai-sandbox-vercel/src/provider.ts
VercelProvider imports withSandboxUserAgent, adds a private fetch field, and passes fetch: this.fetch into Sandbox.create, and Sandbox.get calls in resume and destroy.
Tests and changeset
packages/ai-sandbox-vercel/tests/user-agent.test.ts, .changeset/vercel-sandbox-user-agent.md
Adds a Vitest suite covering token appending/defaulting, header/field preservation, Request input handling, and fallback fetch; adds a changeset documenting the patch.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: AlemTuzlak

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: adding a User-Agent token to ai-sandbox-vercel requests.
Description check ✅ Passed The description follows the template and includes changes, checklist items, testing notes, and release impact.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

marc-vercel and others added 2 commits July 9, 2026 11:52
Identify the TanStack AI framework as a whole rather than this specific
sandbox package.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ange

Revert the JSDoc and changeset rewording accidentally bundled into the
previous commit; keep only the `@tanstack/ai` user-agent token swap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@marc-vercel marc-vercel marked this pull request as ready for review July 9, 2026 10:09
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.

1 participant