Skip to content

fix(sandbox): add workflow serialization support for Snapshot class#140

Open
TooTallNate wants to merge 1 commit intomainfrom
fix/snapshot-workflow-serialization
Open

fix(sandbox): add workflow serialization support for Snapshot class#140
TooTallNate wants to merge 1 commit intomainfrom
fix/snapshot-workflow-serialization

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

Summary

  • Adds WORKFLOW_SERIALIZE / WORKFLOW_DESERIALIZE static methods to the Snapshot class, fixing serialization errors when a Snapshot instance is returned from a workflow step.
  • Uses the same lazy-client pattern as Sandbox and Command: only plain SnapshotMetadata is serialized (credentials are excluded), and an API client is lazily created via ensureClient() when needed after deserialization.
  • Includes 10 tests covering serialize/deserialize roundtrips, credential exclusion, and full dehydrate/hydrate through the workflow runtime pipeline.

Snapshot instances returned from workflow steps failed serialization
because the class lacked WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE methods.
Add these methods following the same lazy-client pattern used by Sandbox
and Command, ensuring credentials are never serialized.
Copilot AI review requested due to automatic review settings April 8, 2026 16:31
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox Ready Ready Preview, Comment, Open in v0 Apr 8, 2026 4:32pm
sandbox-cli Ready Ready Preview, Comment, Open in v0 Apr 8, 2026 4:32pm
sandbox-sdk Ready Ready Preview, Comment, Open in v0 Apr 8, 2026 4:32pm
sandbox-sdk-ai-example Ready Ready Preview, Comment, Open in v0 Apr 8, 2026 4:32pm
workflow-code-runner Ready Ready Preview, Comment, Open in v0 Apr 8, 2026 4:32pm

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds workflow runtime serialization/deserialization support for Snapshot instances in @vercel/sandbox, aligning Snapshot with the existing Sandbox/Command lazy-client pattern so snapshots can safely cross workflow/step boundaries without serializing credentials.

Changes:

  • Added WORKFLOW_SERIALIZE / WORKFLOW_DESERIALIZE static methods to Snapshot, serializing only SnapshotMetadata and lazily recreating the API client via ensureClient() when needed.
  • Updated Snapshot instance methods to use the lazy client initialization path (so deserialized instances still work for API calls).
  • Added a dedicated Vitest suite covering roundtrips, credential exclusion, and workflow runtime pipeline hydration/dehydration.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/vercel-sandbox/src/snapshot.ts Implements workflow serde hooks and lazy client initialization for deserialized Snapshot instances.
packages/vercel-sandbox/src/snapshot.serialize.test.ts Adds integration + unit tests for Snapshot serialization behavior and runtime step-boundary roundtrips.
packages/vercel-sandbox/src/index.ts Re-exports SerializedSnapshot type for consumers.
.changeset/snapshot-workflow-serialization.md Adds a patch changeset documenting the serialization fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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