> ## Documentation Index
> Fetch the complete documentation index at: https://docs.roark.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool Call Testing

> Verify your agent calls the right tools with the right parameters

## Overview

Tool call testing lets you verify that your voice AI agent is invoking the correct tools, with the correct parameters, at the right moments during a conversation. Roark provides built-in metrics for this through the **Tool Invocation Analysis** package.

You can run tool call testing in two contexts:

* **Simulations** — Proactively test tool calling behavior across scenarios before deploying changes
* **Production** — Continuously monitor tool calling quality on live customer calls

Both approaches use the same metrics — you configure the metric once, then apply it wherever you need it.

***

## Prerequisites

Before testing tool calls in either context, you need to set up the tool invocation metrics you want to evaluate.

### 1. Find the Tool Invocation Analysis Package

Navigate to **Metrics > Library** and look for the **Tool Invocation Analysis** package. This package contains five built-in metrics:

| Metric                                 | Type   | What It Measures                                                                   |
| :------------------------------------- | :----- | :--------------------------------------------------------------------------------- |
| **Tool Invocation Correct**            | Yes/No | Whether the agent invoked the correct tools at the appropriate times               |
| **Tool Invocation Count**              | Count  | Total number of tool calls made during the conversation                            |
| **Tool Invocation Order Correct**      | Yes/No | Whether tools were called in the correct logical sequence                          |
| **Tool Invocation Parameters Correct** | Yes/No | Whether the correct parameters were passed to each tool call                       |
| **Tool Invocation Result Correct**     | Yes/No | Whether the agent correctly interpreted and used the results returned by each tool |

### 2. Choose and Configure Your Metrics

Select the metrics relevant to your testing goals. For example, if you want to verify that your agent calls the right tool when a customer asks about the weather:

1. Click on **Tool Invocation Correct** in the library
2. Under **Tool Scoping**, select the specific tool you want to evaluate (e.g., `fetchWeather`)
3. Click **Edit** on the scoped tool to set the evaluation criteria — define when the tool should be called and what result is expected

<img src="https://mintcdn.com/roark/lG_WQkZH-Vmy221z/images/tools/tool-testing.png?fit=max&auto=format&n=lG_WQkZH-Vmy221z&q=85&s=94aa7c047abe2ef2220a9d3f1694fbc5" alt="Tool Scoping Configuration" width="2370" height="1676" data-path="images/tools/tool-testing.png" />

<Tip>
  You can leave tool scoping empty to evaluate all tools, or scope to specific tools for targeted testing. Use the **Additional Instructions** field to add cross-tool rules like "Never call any tool before greeting the customer."
</Tip>

***

## Testing in Simulations

Simulation testing lets you proactively validate tool calling behavior across different scenarios and personas before changes reach production.

<Note>
  Tool call testing in simulations requires **enriched simulations** — your agent must send its call data to Roark so that tool invocation data is available for analysis. See [Enriched Simulations](/documentation/simulation-testing/enriched-simulations) to set this up.
</Note>

### Setup

<Steps>
  <Step title="Create a Run Plan">
    Follow the [run plan guide](/documentation/simulation-testing/run-plans#creating-a-run-plan) to set up your simulation. Choose the scenarios that should trigger the tool calls you want to test.
  </Step>

  <Step title="Add Tool Invocation Metrics">
    In the **Metrics** section of the run plan, select the tool invocation metrics you configured in the prerequisites.
  </Step>

  <Step title="Enable Enriched Simulations">
    Make sure your agent sends its call data to Roark via an [integration](/documentation/integrations/overview) or the [API/SDK](/documentation/observability/overview#how-calls-get-into-roark). This is required for tool call data to be available — without it, Roark only has its simulation agent's recording and cannot see your agent's tool calls.
  </Step>

  <Step title="Run the Simulation">
    Execute the run plan. Once your agent's call is matched and merged with the simulation call, the tool invocation metrics will be evaluated automatically.
  </Step>
</Steps>

***

## Testing in Production

Production testing lets you continuously monitor tool calling quality on live customer calls using metric collectors.

### Setup

<Steps>
  <Step title="Create a Collector">
    Navigate to **Metrics → Collectors** and create a new collector. See the [collectors guide](/documentation/metrics/metric-collectors) for details.
  </Step>

  <Step title="Add Tool Invocation Metrics">
    In the collector, select the tool invocation metrics you configured in the prerequisites.
  </Step>

  <Step title="Set Conditions (Optional)">
    Use collector conditions to filter which calls should be evaluated. For example, you might only want to evaluate tool calls for a specific agent or call direction.
  </Step>

  <Step title="Activate the Collector">
    Once active, the collector will automatically evaluate tool calling on every matching call that comes in.
  </Step>
</Steps>

<Note>
  Your calls must include [tool invocation data](/documentation/tool-invocations) for these metrics to work. Tool calls are automatically captured for **Vapi** and **Retell** integrations. If you use the API directly or LiveKit, you must include tool invocations when creating calls.
</Note>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Tool Invocations" icon="wrench" href="/documentation/tool-invocations">
    Learn how to submit tool call data with your calls
  </Card>

  <Card title="Enriched Simulations" icon="sparkles" href="/documentation/simulation-testing/enriched-simulations">
    Enable call matching for simulation tool testing
  </Card>

  <Card title="Collectors" icon="shield-check" href="/documentation/metrics/metric-collectors">
    Automate metric collection on production calls
  </Card>

  <Card title="Run Plans" icon="list-checks" href="/documentation/simulation-testing/run-plans">
    Set up simulation test matrices
  </Card>
</CardGroup>
