Skip to content

fix(sandbox-vercel): forward credentials when resuming sessions#16500

Open
doneumark wants to merge 2 commits into
vercel:mainfrom
doneumark:fix/sandbox-vercel-resume-credentials
Open

fix(sandbox-vercel): forward credentials when resuming sessions#16500
doneumark wants to merge 2 commits into
vercel:mainfrom
doneumark:fix/sandbox-vercel-resume-credentials

Conversation

@doneumark

Copy link
Copy Markdown

Background

@ai-sdk/sandbox-vercel forwards Vercel Sandbox create settings into Sandbox.create() and Sandbox.getOrCreate(), including access-token credentials (token, teamId, projectId). However, resumeSession() reattaches by calling Sandbox.get({ name }) without forwarding those settings.

In non-Vercel environments that use access-token auth, first session creation succeeds but a later agent.createSession({ sessionId, resumeFrom }) can fail when the provider tries to resume the named sandbox and @vercel/sandbox falls back to OIDC:

Could not get credentials from OIDC context.
Please link your Vercel project using `npx vercel link`.
Then, pull an initial OIDC token with `npx vercel env pull`
and retry.

Summary

  • Forward reusable sandbox lookup credentials into Sandbox.get() from resumeSession().
  • Forward the same lookup credentials when polling for a template snapshot after Sandbox.getOrCreate().
  • Add a regression test asserting named session resume forwards token, teamId, projectId, and signal.
  • Add a patch changeset for @ai-sdk/sandbox-vercel.

Manual Verification

I verified the failure mode against the installed package source by reproducing the code path where createSession() uses access-token settings but resumeSession() calls Sandbox.get({ name }) without them. The updated unit test covers the credential forwarding needed for that path.

Automated checks run locally:

pnpm --filter @ai-sdk/provider-utils build
pnpm --filter @ai-sdk/sandbox-vercel test
pnpm --filter @ai-sdk/sandbox-vercel type-check
pnpm --filter @ai-sdk/sandbox-vercel build
pnpm exec ultracite fix packages/sandbox-vercel/src/vercel-sandbox.ts packages/sandbox-vercel/src/vercel-sandbox.test.ts .changeset/tidy-sandboxes-resume.md

Note: pnpm --filter @ai-sdk/harness build was also attempted after building @ai-sdk/provider-utils, but its DTS build failed resolving @ai-sdk/provider-utils declarations. The focused @ai-sdk/sandbox-vercel tests/typecheck/build pass after dependencies are installed.

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues

No existing issue found when searching vercel/ai and vercel/sandbox for sandbox-vercel resumeSession Sandbox.get credentials.

Made with Cursor

@doneumark doneumark force-pushed the fix/sandbox-vercel-resume-credentials branch from 4c2b7f0 to 06aa1dc Compare June 30, 2026 01:24
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