Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • explicitly install shims module from anthropic and openai in stagehand route

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 13, 2025

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 13, 2025 3:22am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 13, 2025

Greptile Overview

Greptile Summary

This PR fixes build/deployment issues for the Stagehand API routes by ensuring Anthropic and OpenAI SDK modules are properly available in serverless environments.

  • Added shims imports (@anthropic-ai/sdk/shims/node, openai/shims/node) to both stagehand route files to load Node.js polyfills required by these SDKs
  • Re-added @anthropic-ai/sdk and openai to serverExternalPackages in Next.js config (previously removed in fix(next): remove openai and anthropic sdk's from serverExternalPackages #2349)
  • Added outputFileTracingIncludes configuration to ensure SDK modules are bundled with the stagehand API routes during deployment

This is a straightforward build configuration fix with no logic changes to the API routes themselves.

Confidence Score: 5/5

  • This PR is safe to merge - straightforward build configuration fix with no logic changes.
  • The changes are minimal and well-scoped build configuration fixes. The shims imports are added at the top of files as required for proper initialization. The serverExternalPackages and outputFileTracingIncludes settings follow standard Next.js patterns for handling native Node.js modules in serverless environments.
  • No files require special attention.

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/api/tools/stagehand/agent/route.ts 5/5 Added shims imports for Anthropic and OpenAI SDKs at top of file to ensure proper Node.js polyfills are loaded for serverless deployment.
apps/sim/app/api/tools/stagehand/extract/route.ts 5/5 Added shims imports for Anthropic and OpenAI SDKs at top of file to ensure proper Node.js polyfills are loaded for serverless deployment.
apps/sim/next.config.ts 5/5 Re-added @anthropic-ai/sdk and openai to serverExternalPackages. Added outputFileTracingIncludes to bundle stagehand-related SDK modules for serverless deployment.

Sequence Diagram

sequenceDiagram
    participant Client
    participant NextJS as Next.js Server
    participant Shims as SDK Shims
    participant Stagehand as Stagehand API
    participant SDK as Anthropic/OpenAI SDK
    participant BB as Browserbase

    Client->>NextJS: POST /api/tools/stagehand/*
    NextJS->>Shims: Load Node.js polyfills
    Shims-->>NextJS: Polyfills ready
    NextJS->>Stagehand: Initialize route handler
    Stagehand->>SDK: Initialize SDK client
    SDK->>BB: Connect to Browserbase
    BB-->>SDK: Browser session
    SDK-->>Stagehand: Agent/Extract result
    Stagehand-->>Client: JSON response
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 821d127 into staging Dec 13, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/shh branch December 13, 2025 03: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.

2 participants