Function Tools
Copy page
Create custom JavaScript functions that your agents can execute directly in the Visual Builder
Function tools allow you to create custom JavaScript functions that agents can execute in secure sandboxes. Unlike MCP servers that connect to external services, function tools run your own code directly within the agent framework.
Overview
Function tools are ideal for:
- Custom business logic - Implement domain-specific calculations or workflows
- Data processing - Transform, validate, or analyze data using JavaScript
- API integrations - Connect to services that don't have MCP servers
- Utility functions - Create reusable helper functions across your agents
Creating Function Tools
Function tools are created within an Agent and can be used by multiple Sub Agents in that Agent.
In an Agent
-
Add a Function Tool Node: In the Agent editor, drag a "Function Tool" node from the node palette onto the canvas
-
Configure the Function Tool: Click on the function tool node to open the configuration panel in the right sidebar:
Field | Description |
---|---|
Name | A unique name for your function tool (e.g., "calculate_tax") |
Description | What the function does and when to use it |
Code | The JavaScript function code to execute |
Input Schema | JSON Schema defining the function parameters |
Dependencies | NPM packages required by your function |
- Connect to Agents: Drag from the function tool node to any agent nodes that should have access to this tool

Function Code
Write your JavaScript function in the Code editor. The function receives arguments based on your Input Schema and should return a result:
Input Schema
Define the parameters your function accepts using JSON Schema. This ensures proper validation and helps agents understand how to use your function:
The Visual Builder provides syntax highlighting and validation for your JSON schema.
Dependencies
If you need external packages for your code to run, then specify the desired version in dependencies; otherwise we always use the latest version.
Manual Override: Specify dependencies in the Dependencies field to pin to specific versions:
Example: Weather API Integration
Here's a complete example of a function tool that fetches weather data:
Name: get_current_weather
Description: Get current weather information for any city using OpenWeatherMap API
Code:
Input Schema:
Dependencies:
Execution Environment
Function tools run in secure, isolated sandboxes that provide a safe execution environment for your code.
Sandbox Execution
Functions execute with the following characteristics:
- Isolated execution - Each function runs in its own sandbox
- No file system access - Cannot read or write outside the sandbox
- Network access - Only through explicitly declared dependencies (like axios)
- Resource limits - CPU, memory, and execution time constraints enforced
- Stateless execution - No data persists between function calls
Runtime Options
When deploying, you can configure:
- Runtime: Node.js 22 or TypeScript
- Timeout: Maximum execution time per function call
- Concurrency: Number of simultaneous function executions
See Deploy to Vercel for deployment-specific configuration.
Best Practices
- Keep functions simple - Each function should have a single, clear purpose
- Minimize dependencies - Only include packages you actually need for better performance
- Handle errors - Always catch and return meaningful error messages
- Test thoroughly - Test your functions independently before deploying
- Clear descriptions - Write descriptive names and descriptions to help agents use tools effectively
Function tools provide powerful customization capabilities while maintaining security and performance through sandboxed execution.