Skip to content

Conversation

@tkattkat
Copy link
Collaborator

@tkattkat tkattkat commented Jan 5, 2026

why

currently using custom tools requires importing from a separate package

what changed

  • exported tool function & type
  • added test for exported function and type

test plan

wrote tests & tested locally


Summary by cubic

Exported the tool function and Tool type from Stagehand core so users can define custom tools without installing an extra package. Added tests to confirm the exports and usage.

Written for commit 752ee8d. Summary will update on new commits.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: 752ee8d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 5, 2026

Greptile Summary

This PR exports the tool function and Tool type from the ai package through Stagehand's public API, allowing users to define custom tools without directly installing the ai package dependency.

Key Changes:

  • Exported tool function from packages/core/lib/v3/index.ts
  • Re-exported Tool type from packages/core/lib/v3/types/public/agent.ts
  • Added comprehensive test suite verifying both function and type exports work correctly
  • Updated existing public API tests to include new exports
  • Added changeset documenting the patch-level change

Benefits:

  • Simplifies custom tool creation by providing tool function directly from @browserbasehq/stagehand
  • Improves developer experience by reducing required dependencies
  • Maintains type safety with properly exported Tool type
  • Follows existing pattern of re-exporting ModelMessage from ai package

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are minimal and well-tested. The PR only exports existing functionality from the ai package without modifying any internal logic. Comprehensive tests verify both runtime function export and type compatibility. The changes follow established patterns (similar to ModelMessage re-export) and include proper changeset documentation.
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/lib/v3/index.ts Exports tool function from ai package to enable custom tool creation
packages/core/lib/v3/types/public/agent.ts Re-exports Tool type from ai package for consumer tool definitions
packages/core/tests/public-api/tool-type-export.test.ts New comprehensive test suite validating tool function and type exports work correctly

Sequence Diagram

sequenceDiagram
    participant User as Developer
    participant Stagehand as @browserbasehq/stagehand
    participant AI as ai package
    
    Note over User,AI: Custom Tool Creation Flow
    
    User->>Stagehand: import { tool, Tool } from '@browserbasehq/stagehand'
    Stagehand->>AI: Re-export tool function
    Stagehand->>AI: Re-export Tool type
    AI-->>Stagehand: tool function
    AI-->>Stagehand: Tool type
    Stagehand-->>User: tool function & Tool type
    
    Note over User: Define custom tool
    User->>User: const customTool = tool({ description, inputSchema, execute })
    
    Note over User: Use with agent
    User->>Stagehand: stagehand.agent({ tools: { customTool } })
    Stagehand->>Stagehand: Register custom tool with agent
    
    Note over User: Execute agent with custom tool
    User->>Stagehand: agent.execute({ instruction })
    Stagehand->>Stagehand: Agent can call customTool during execution
Loading

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

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.

3 participants