Skip to main content

Overview

Use withTool(options, fn) to trace tool or function calls within agents. Tools represent specific capabilities that agents can invoke.

Signature

Basic Usage

Tools within an Agent

API Integration Tool

Database Query Tool

Custom Calculator Tool

Parameters

string
required
Tool display name for identification in the Keywords AI dashboard
number
Version number for tracking tool iterations
Record<string, any>
Custom metadata to associate with the tool (inputs, configuration, etc.)

Return Value

Returns a Promise that resolves to the return value of the provided function.

Best Practices

  • Use tools for specific capabilities that agents can invoke
  • Name tools clearly to reflect their function
  • Always nest tools within agents for proper hierarchy
  • Add association properties to track tool inputs and configuration
  • Tools are automatically linked to their parent agent in traces
  • Tools can be reused across multiple agents