What You’ll Build
Multi-tool agents that:- Use multiple specialized tools together
- Work with both AI SDK and Mastra
- Mix tools from different sources
- Automatically handle tool format conversion
Prerequisites
Example 1: AI SDK with Multiple Tools
Example 2: Mastra with Mixed Tool Formats
Example 3: Complete Multi-Tool Application
Step-by-Step Walkthrough
Define Multiple Tools
Create separate tools for different functionalities:Each tool has a focused, single responsibility.
Add All Tools to Builder
Chain multiple
withTool() calls:PromptSmith automatically handles tool deduplication and validates that tool names are unique.
Mix Tool Formats (Mastra Only)
Combine Mastra and PromptSmith tool formats:Tools are automatically converted to the correct format.
Set Tool Usage Constraints
Guide how tools should be used together:This ensures the agent uses tools effectively.
Export to Your Framework
Convert to AI SDK or Mastra format:All tools are automatically converted to the target format.
Expected Output
Running the complete example produces:Key Concepts
Tool Composition - Multiple specialized tools are better than one complex tool. Each tool should have a single, well-defined responsibility.
Framework Compatibility - PromptSmith automatically converts tools between formats. Define tools once, use everywhere.
Mastra Tool Support - Tools created with Mastra’s
createTool() work seamlessly with PromptSmith. No manual conversion needed.Validation - Always validate agents with multiple tools to catch duplicate names and configuration issues before deployment.
Best Practices
Tool Naming
Use clear, descriptive names:Tool Organization
Group related tools:Error Handling
Handle errors in tool execution:Advanced Use Cases
Dynamic Tool Loading
Conditional Tool Sets
Next Steps
Tools Guide
Learn advanced tool patterns and best practices
AI SDK Integration
Deep dive into Vercel AI SDK integration