ThunderPhone v3 is live.Self-serve, from 2¢/min.Read the announcement

Function Tools

Function Tools

Give your AI agents function tools that call external APIs mid-conversation — fetch customer data, book appointments, update records — with typed parameters.

Function tools allow your AI agents to invoke external APIs during phone calls. Use them to look up customer data, check availability, book appointments, or perform any action your backend supports.

How It Works

  1. You define tools with a schema (what arguments the tool accepts)
  2. You provide an endpoint configuration (where ThunderPhone calls your API) — or leave it off to receive tool calls on your org webhook
  3. During a call, the AI decides when to use a tool based on the conversation
  4. ThunderPhone calls your endpoint with the tool arguments
  5. Your API response is fed back to the AI to continue the conversation
CapabilityWhere it runsSetup
Built-in toolsThunderPhonePrompt instructions; some tools also need an agent setting
App connectionsThunderPhone and the connected providerConnect the account and attach approved actions
API connections and function toolsYour HTTP APIDefine the endpoint and schema, or receive function calls through a webhook
MCP serversA remote MCP serverAdd the server, discover its tools, and attach it to the agent

Tool Schema

Each tool follows this structure:

{
  "type": "function",
  "function": {
    "name": "search_appointments",
    "description": "Find available appointment slots for a given date",
    "parameters": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string",
          "description": "Date in YYYY-MM-DD format"
        },
        "service": {
          "type": "string",
          "description": "Type of service (e.g., 'consultation', 'follow-up')"
        }
      },
      "required": ["date"]
    }
  },
  "endpoint": {
    "url": "https://api.example.com/appointments/search",
    "method": "POST",
    "headers": {
      "X-Api-Key": "your-api-key"
    }
  },
  "timeout": 120
}

Tool Configuration

FieldTypeRequiredDescription
timeoutnumberNoMaximum execution time in seconds (default: 20, maximum: 180, or 600 with wait_mode "hold" or "background")
wait_modestringNoWhat happens on the call while the tool runs: updates (default), short spoken updates; hold, hold music (see Long waits: hold mode and answer later); or background, the agent keeps talking and gets the result when it comes back (see Background tools)
call_startobjectNoAlso run the tool automatically at the start of every phone call, before the greeting. See Run a tool at the start of the call

Function Definition

FieldTypeRequiredDescription
namestringYesIdentifier for the tool, unique among the tools of one call. Different agents may each have their own tool with the same name
descriptionstringYesExplains to the AI when to use this tool
parametersobjectYesJSON Schema for tool arguments

Endpoint Configuration

FieldTypeRequiredDescription
urlstringYesYour API endpoint URL
methodstringNoHTTP method (default: POST)
headersobjectNoCustom headers to include

Two invocation paths

Which request your server receives depends on whether the tool has an endpoint:

Tool with endpointTool without endpoint
Where the request goesDirectly to endpoint.urlYour org's legacy webhook URL
BodySelected request format (bare arguments by default)telephony.tool / web.tool envelope
HeadersYour endpoint.headers + X-ThunderPhone-Call-ID + X-ThunderPhone-Signature-V2 + X-ThunderPhone-Signature, plus the call's numbers on phone callsContent-Type + X-ThunderPhone-Signature-V2 + X-ThunderPhone-Signature
Signing keyOrg webhook secretOrg webhook secret

By default both paths are blocking: the agent waits for the result before it goes on. The default timeout is 20 s; set the tool's top-level timeout to allow a longer execution, up to the 180 s platform maximum. Keep handlers fast. For waits on a person or a slow job, use hold mode. For a lookup the call can go on without, use background mode. A mix is fine: on a call whose org has a webhook URL, tools with an endpoint are called directly and the rest fall back to the webhook.

Direct endpoint calls

When the AI invokes a tool that has an endpoint, ThunderPhone sends a request to your URL:

Request Headers

POST /appointments/search HTTP/1.1
Host: api.example.com
Content-Type: application/json
X-ThunderPhone-Signature-V2: t=1767225600,v1=5f2c...
X-ThunderPhone-Signature: abc123...
X-ThunderPhone-Call-ID: 987654321
X-ThunderPhone-From-Number: +14155550199
X-ThunderPhone-To-Number: +14155550100
X-ThunderPhone-Call-Direction: inbound
X-Api-Key: your-api-key

Custom headers from your endpoint.headers are always included verbatim, plus these ThunderPhone-namespaced headers:

  • X-ThunderPhone-Signature-V2 — timestamped HMAC-SHA256 over the method, path, query and body, keyed with your org webhook secret. Verify this one and reject requests more than 5 minutes old; see Verify webhook signatures
  • X-ThunderPhone-Signature — legacy HMAC-SHA256 of the exact request-body bytes, same key, still sent for existing verifiers
  • X-ThunderPhone-Call-ID — The current call ID
  • X-ThunderPhone-From-Number and X-ThunderPhone-To-Number — the call's From and To numbers in E.164. They mean the same as from_number and to_number in telephony.complete: on an outbound call, From is your agent's number and To is the person called. A number is left out when the caller ID is withheld or isn't a phone number
  • X-ThunderPhone-Call-Direction — inbound or outbound, so you can tell which number is the customer's

The call-number headers are sent on phone calls only. Web, widget, realtime and browser Talk tests have no phone number and leave them out. Test calls from the agent editor and AI simulations carry the simulated caller's number. The signatures do not cover headers: V2 signs the timestamp, method, path, query and body. If you need the numbers signed, read them from the body instead: the retell request format carries all three, and vapi carries the customer's number.

Content-Type: application/json is set unless your endpoint.headers override it — a custom Content-Type wins.

Request format

Each API connection has a request_format setting. Choose vapi or retell when an imported tool should keep calling an endpoint built for that platform. New and existing connections default to standard.

For POST / PUT / PATCH, ThunderPhone serializes the selected envelope canonically (sorted keys, compact separators). Both signatures cover these exact bytes.

Standard

standard sends only the tool arguments, with no wrapper. This is the default and preserves ThunderPhone's original request body byte for byte:

{"date":"2025-01-02","service":"consultation"}

Vapi

vapi sends Vapi's tool-calls server message in the shape Vapi documents. The call.id is the ThunderPhone call ID. On phone calls, call.customer.number is the other party's number, as in Vapi's call object: the caller on an inbound call, the person called on an outbound one. It is left out when that number is withheld or isn't a phone number. The tool-call id is unique to the invocation and is reused to match the endpoint's result. The call appears in both toolCallList and toolWithToolCallList, with function.arguments as a JSON object:

{
  "message": {
    "type": "tool-calls",
    "timestamp": 1725000000123,
    "call": { "id": "987654321" },
    "toolCallList": [
      {
        "id": "call_00112233445566778899aabbccddeeff",
        "type": "function",
        "function": {
          "name": "search_appointments",
          "arguments": { "date": "2025-01-02", "service": "consultation" }
        }
      }
    ],
    "toolWithToolCallList": [
      {
        "type": "function",
        "function": { "name": "search_appointments" },
        "toolCall": {
          "id": "call_00112233445566778899aabbccddeeff",
          "type": "function",
          "function": {
            "name": "search_appointments",
            "arguments": { "date": "2025-01-02", "service": "consultation" }
          }
        }
      }
    ]
  }
}

Vapi-only fields such as assistant, artifact and the full call object are not sent.

Return Vapi's response envelope with the matching tool-call ID:

{
  "results": [
    {
      "toolCallId": "call_00112233445566778899aabbccddeeff",
      "result": "{\"available_slots\":[\"9:00 AM\",\"2:00 PM\"]}"
    }
  ]
}

ThunderPhone gives the AI the unwrapped result string. It also accepts a JSON value for compatibility with endpoints that already return one. An error in place of result is returned to the AI as a tool error. If the endpoint returns a malformed or mismatched Vapi envelope, ThunderPhone logs a warning and falls back to its standard response parsing instead of failing the call.

Retell

retell sends the request documented for a Retell custom function:

{
  "name": "search_appointments",
  "call": {
    "call_id": "987654321",
    "from_number": "+14155550199",
    "to_number": "+14155550100",
    "direction": "inbound"
  },
  "args": { "date": "2025-01-02", "service": "consultation" }
}

On phone calls, the call object carries call_id, from_number, to_number and direction (inbound or outbound), the field names Retell's phone call object uses. They match the call-number headers, and unlike the headers they are covered by both signatures. A number that is withheld or isn't a phone number is left out. On web, widget, realtime and browser Talk tests it holds only call_id. ThunderPhone does not include Retell-specific fields it cannot honestly supply at dispatch, such as agent_id, transcript, transcript_object, metadata, or dynamic variables. Retell accepts any response body; ThunderPhone passes it through using the standard response handling.

For GET / DELETE, the arguments are sent as query parameters and the body is empty regardless of request_format. The V2 signature covers the query string as sent; the legacy signature is computed over the empty byte string. See Verify webhook signatures.

Response

Return a JSON response with the tool result:

{
  "available_slots": ["9:00 AM", "2:00 PM", "4:30 PM"],
  "timezone": "America/Los_Angeles"
}

The response is formatted and provided to the AI to continue the conversation. Non-JSON responses are wrapped as {"data": "<text>"}; timeouts and connection failures are reported to the AI as errors, so the agent can apologize and move on rather than stall.

Webhook-mode dispatch

Tools without an endpoint are dispatched to your org's legacy webhook URL as a signed telephony.tool (phone calls) or web.tool (web calls) request. Unlike the audit notifications delivered to webhook endpoints after execution, this request is the execution — your HTTP response is the tool result.

{
  "type": "telephony.tool",
  "data": {
    "call_id": 987654321,
    "tool_name": "search_appointments",
    "arguments": { "date": "2026-04-21" },
    "from_number": "+14155550199",
    "to_number": "+15551234567"
  }
}

web.tool carries origin_domain instead of from_number / to_number. Respond with the tool result as JSON — the same response contract as direct endpoint calls. The request is signed with the org webhook secret, with both signature headers, like every other webhook.


Long waits: hold mode and answer later

Some tools wait on a person: a manager approving a discount, an owner answering a question in Slack. Set wait_mode to "hold" on those tools.

wait_mode: "updates" (default)wait_mode: "hold"wait_mode: "background"
What the caller hearsThe tool-start line, then a short "still working" line after about 12 s and another every 15 s or soThe tool-start line, then hold music until the result arrivesThe conversation goes on; no music or update lines (background tools)
timeout maximum180 s600 s600 s
Pending answersPassed to the agent as the resultThe tool stays open until you deliver the resultThe agent keeps talking until you deliver the result

In hold mode the agent says one line as the tool starts (its own words, or the tool-start line set on the agent), then the caller hears hold music. The music fades out before the agent speaks the result. A tool that answers within a second or two gets no music at all. When the agent is talking to a phone menu or a voicemail box, it uses spoken updates instead, since music could be heard as a reply. That includes a call found to be a menu or mailbox mid-hold: the music stops and spoken updates take over. So does a call where the music can't play.

If the caller speaks during the hold, the music keeps playing and the agent does not answer yet. It hears what the caller said and replies to it along with the result. A hang-up ends the call and the open tool.

Answer later

Your endpoint's own response still has to arrive within 180 s. To hold the caller longer, answer right away with a pending result:

{ "status": "pending", "request_id": "ask-4471" }

request_id is any string up to 200 characters that identifies this request on your side. With a hold tool, the caller stays on hold until you deliver the result for it; with a background tool, the agent keeps talking in the meantime. Deliver it with POST /v1/calls/{call_id}/tool-results. The call_id is the X-ThunderPhone-Call-ID header of the tool request.

curl -X POST https://api.thunderphone.com/v1/calls/987654321/tool-results \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "ask-4471",
    "result": { "answer": "Yes, book Tuesday at 10." }
  }'

The agent reads result as the tool's answer, the same as if your endpoint had returned it. If no result arrives before the tool's timeout, counted from when the tool was called, the agent is told no answer came back. A hold tool's agent then offers the caller next steps, such as taking a message; a background tool's agent carries on without the result.

You can post the result as soon as you like, even before your pending response has reached ThunderPhone. A 202 means the call accepted it: an open request took it, or the tool's own request is still in flight and its pending answer will claim it. A result that no request ever claims (your endpoint then answered something other than pending for that request_id) is dropped.

If the connection has a response transform (code that rewrites your endpoint's reply before the agent sees it), the transform runs on your endpoint's own reply, before ThunderPhone checks for a pending answer, so it must keep status and request_id in a pending reply. It does not run on a result you post later: the agent gets that result as you send it.

A full-duplex agent has no hold music or update lines, so on its calls a hold tool behaves like an updates tool: a pending answer reaches the agent as the tool's result.

A pending response from a tool in updates mode is not held open: the agent receives it as the tool's result.

Background tools

Some lookups take a while, but the call doesn't have to stop for them: a credit check that runs while the agent asks its next questions, or a quote the agent only needs near the end of the call. Set wait_mode to "background" on those tools.

When the agent calls a background tool, it is told the tool has started, and it keeps talking. The caller can talk normally: nothing is held back, and there's no hold music. When your endpoint answers, the result is added to the conversation at the next pause, once the agent has finished speaking and nobody is in the middle of a turn. The agent uses it the next time it speaks. It doesn't interrupt anyone to announce it.

The agent decides for itself when it needs the result. Your endpoint is called once per run:

  • The result is needed now. The agent calls the same tool again with the same arguments. No second request goes out: the agent waits for the one already running, with the usual spoken updates, for up to 90 seconds. If the result still isn't back, the agent carries on and the result is added when it arrives.
  • The result is already in. The same call with the same arguments gets that result at once, without a new request.
  • The run failed. The same call runs the tool again.
  • Different arguments start a new run. A call can have up to three background tools running at once; a fourth isn't started, and the agent is told to wait for one of the others to finish.

When to use it

Use background mode for lookups and long jobs the conversation can go on without. Don't use it for actions the caller must hear confirmed, such as a booking, a payment or a cancellation. The agent would carry on before it knows whether the action worked. Keep those tools in updates or hold mode.

Timeouts and answer later

Your endpoint's own response still has to arrive within 180 s. A background tool can run longer, up to a timeout of 600 s, with answer later: answer at once with {"status": "pending", "request_id": "..."} and deliver the result with POST /v1/calls/{call_id}/tool-results. The agent keeps talking while it waits. The timeout counts from when the agent first called the tool. If the tool fails, or no result arrives in time, the agent is told so and carries on without it.

Build the endpoint for it

  • Make it safe to abandon. A hang-up doesn't wait for a background tool: the call ends, ThunderPhone closes its request to your endpoint, and a result posted to tool-results after that gets a 409. Anything your endpoint already did, such as writing a record, stays done. We can't undo it.
  • Expect overlapping requests. The call goes on while the tool runs, so your server can get another request for the same call before the first one has answered. If your integration keeps state per call, make sure two requests for one call can run at the same time.

Where it runs

Most calls run background tools in the background. Two exceptions run the tool the ordinary way, as an updates tool, where the agent waits for the result before it goes on:

  • calls on a full-duplex agent (one that listens and speaks at the same time), and
  • a tool the agent calls while checking in after a silence.

There, a pending answer reaches the agent as the tool's result, so answer later doesn't work, and the timeout is capped at 180 s.

Signature Verification

Direct tool calls are signed the same way as webhooks, keyed with your org webhook secret:

  • X-ThunderPhone-Signature-V2 signs the timestamp, method, path and query as sent, and the exact body bytes. Reject requests whose timestamp is more than 5 minutes from your clock.
  • X-ThunderPhone-Signature (legacy) signs only the body bytes, the empty byte string for GET / DELETE. It is still sent, unchanged.

The SDK helpers check the V2 header, including the 5-minute window:

Python
import json
 
from fastapi import FastAPI, HTTPException, Request
from thunderphone import verify_signature
 
app = FastAPI()
 
@app.post("/appointments/search")
async def search_appointments(request: Request):
    body = await request.body()
    query = request.scope.get("query_string", b"").decode("latin-1")
    path = request.url.path + (f"?{query}" if query else "")
 
    if not verify_signature(
        request.headers.get("X-ThunderPhone-Signature-V2"),
        secret=WEBHOOK_SECRET,
        method=request.method,
        path=path,
        body=body,
    ):
        raise HTTPException(status_code=401)
 
    data = json.loads(body)
    date = data["date"]
 
    # Look up availability
    slots = await get_available_slots(date)
 
    return {"available_slots": slots}
Node.js
import express from "express";
import { verifySignature } from "@thunderphone/sdk";
 
app.post('/appointments/search', express.raw({type: 'application/json'}), (req, res) => {
  const ok = verifySignature({
    header: req.header('X-ThunderPhone-Signature-V2'),
    secret: WEBHOOK_SECRET,
    method: req.method,
    path: req.originalUrl,
    body: req.body,
  });
  if (!ok) return res.status(401).send('Invalid signature');
 
  const { date, service } = JSON.parse(req.body);
 
  // Look up availability
  const slots = getAvailableSlots(date, service);
 
  res.json({ available_slots: slots });
});

Full recipes — the signed string, a worked example, code without the SDK, the GET / DELETE case and the no-secret caveat — are in Verify webhook signatures.


Example: Complete Booking Flow

Here's a set of tools for a complete appointment booking system:

{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "search_appointments",
        "description": "Find available appointment slots",
        "parameters": {
          "type": "object",
          "properties": {
            "date": { "type": "string", "description": "YYYY-MM-DD" },
            "service": { "type": "string" }
          },
          "required": ["date"]
        }
      },
      "endpoint": {
        "url": "https://api.example.com/appointments/search",
        "method": "POST",
        "headers": { "X-Api-Key": "key" }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "book_appointment",
        "description": "Book an appointment at a specific time",
        "parameters": {
          "type": "object",
          "properties": {
            "date": { "type": "string", "description": "YYYY-MM-DD" },
            "time": { "type": "string", "description": "HH:MM format" },
            "customer_name": { "type": "string" },
            "customer_phone": { "type": "string" }
          },
          "required": ["date", "time", "customer_name"]
        }
      },
      "endpoint": {
        "url": "https://api.example.com/appointments/book",
        "method": "POST",
        "headers": { "X-Api-Key": "key" }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "cancel_appointment",
        "description": "Cancel an existing appointment",
        "parameters": {
          "type": "object",
          "properties": {
            "confirmation_number": { "type": "string" }
          },
          "required": ["confirmation_number"]
        }
      },
      "endpoint": {
        "url": "https://api.example.com/appointments/cancel",
        "method": "POST",
        "headers": { "X-Api-Key": "key" }
      }
    }
  ]
}

Run a tool at the start of the call

A tool can also run automatically at the start of every phone call, before the agent says its first word, so the greeting can use the result. The usual case is a CRM lookup by the caller's number: "Welcome back, Arthi! Would you like your usual order?"

In the app, ask Zeus to run the API at the start of every call (its page under Integrations → APIs & MCP shows when it runs). In the old view, open the API connection and set When it runs to At the start of every phone call, then fill in the value each parameter gets. Through the API, set the integration's trigger to call_start and its call_start_arguments (API connections), or add a call_start block to an inline tool:

{
  "type": "function",
  "function": {
    "name": "get_contact_by_phone",
    "description": "Look up a customer by phone number.",
    "parameters": {
      "type": "object",
      "properties": {
        "business_id": {"type": "string"},
        "phone_number": {"type": "string"}
      },
      "required": ["business_id", "phone_number"]
    }
  },
  "endpoint": {"url": "https://crm.example.com/contacts/lookup"},
  "call_start": {
    "arguments": {
      "business_id": "a0a81c23",
      "phone_number": "{{caller_number}}"
    }
  }
}

The arguments need a value for every required parameter, since nobody fills anything in at call start. Values are strings, numbers or booleans. They are stored and returned as plain text and the agent sees them, so keep secrets such as API keys in the connection's headers, not here. Strings can use these placeholders:

PlaceholderValue
{{caller_number}}The other person on the call in E.164 format, e.g. +61402122887: the caller on an inbound call, the person called on an outbound call
{{caller_number_national}}The same number in its country's national format without spaces, e.g. 0402122887
{{agent_number}}The agent's own number

How it behaves:

  • The request is the same one the agent's own tool calls send (same endpoint, headers, request format and signature).
  • The tool starts when the call starts, and runs while any connect tone, intro or recording notice plays. The greeting waits for it for up to about 3 seconds from that point. A slower result is given to the agent as soon as it arrives, for the rest of the call. On an outbound call it starts when the call is placed, so it runs on every attempt, including ones nobody answers.
  • On an agent where the caller speaks first there is no greeting to wait for; the agent gets the result as soon as it arrives.
  • The result is given to the agent as context for the whole call. Tell the agent in your prompt how to use it; it is not read out otherwise.
  • If the tool fails or times out, the agent greets the caller as it normally would and says nothing about it.
  • The agent can still call the tool itself later in the call.
  • It runs on phone calls, including test calls to your phone, and on AI simulations, which send the simulated caller's number to your endpoint. It does not run in browser test calls or web widget sessions, which have no caller number, on calls whose caller ID is withheld, or on agents with steps.
  • An agent runs at most three call-start tools, all at once.

Mention the result in your prompt so the agent knows how to use it, for example: "If the call start lookup found the caller, greet them by first name."


Run a tool when the call ends

An agent can also have one of its tools run automatically after every call ends, however it ended: the caller hung up, a voicemail picked up, the agent ended the call, or it transferred the caller. The usual case is saving each call's outcome to your CRM. A tool the agent only calls when it remembers to, or when the caller stays on the line long enough, misses the calls where the person hangs up first; an end-of-call tool doesn't, and you don't need to build a receiver for the call-complete webhook.

In the app, open the agent's Tools and set After each call, or ask Zeus to run the tool after every call. Through the API, set the agent's end_of_call_tool (Agents):

{
  "end_of_call_tool": {
    "tool": "save_call_end",
    "when": "every_call",
    "skip_if_called": true
  }
}
FieldDescription
toolThe function name of one of the agent's own API tools: one with an endpoint, or one answered on your organization webhook. Built-in tools (such as send_email or send_sms), MCP tools and app-connection tools can't run after the call
whenevery_call (default): every call that connected, voicemail and quick hang-ups included. answered: only calls a person answered: inbound and web calls, and outbound calls (including SIP calls your dialer marks outbound) where the call's answered_by is human. A voicemail, a call screener, a phone menu or unknown (no one was heard) is skipped
skip_if_calledDefault true: skip a call where the agent already ran the tool successfully during the call, so a tool your prompt already asks for isn't sent twice. A call where the tool failed still gets it

{} turns it off. Like other agent settings it is staged in the draft and goes live when the agent is deployed; test calls use the draft.

What the tool receives

ThunderPhone fills in the tool's parameters from the call:

  • A parameter named after one of these call facts gets the call's own value, with the same meaning as in telephony.complete: call_id, direction, from_number, to_number, end_reason, answered_by, duration_seconds, started_at and ended_at. Declare them in the tool's parameters to receive them.
  • Every other parameter is filled from the conversation, the way the agent would have filled it if it had called the tool as the call ended. A value the call doesn't establish is null for a required parameter and left out for an optional one. A value that doesn't fit the parameter's type or enum is treated the same way.
  • Nothing is read from the conversation when the call wasn't recorded or when the agent's call review is off: the tool then gets the call facts, and null for everything else.

The request is the same one the agent's own tool calls send: the same endpoint, method, headers, request format, transforms, signatures and timeout. It adds two headers:

  • X-ThunderPhone-Tool-Trigger: call_end
  • X-ThunderPhone-Idempotency-Key: <call_id>:<tool name>:call_end, the same on every attempt

Delivery is at least once: in rare cases (a retry after a request whose answer was lost, or a call whose ending was revised) your endpoint can get the same call's request twice. Use the idempotency key to ignore a repeat.

Timing, retries and results

  • It runs within seconds of the call ending, in the background: it never delays the call-complete webhook.
  • A timeout, an unreachable endpoint, a 408, a 429 or a 5xx answer is retried, with the same arguments, up to 3 attempts in all. Other 4xx answers are final.
  • Nothing is sent more than 30 minutes after the call ended: an attempt that late is recorded as failed with the reason expired. An expired run sends no telephony.tool event.
  • Calls that never connected (an outbound call nobody answered, a call refused before it started) don't run it.
  • The outcome is on the call as end_of_call_tool (Calls): sent, failed or skipped and why, the arguments sent and your endpoint's answer. Subscribed webhook endpoints also get the telephony.tool / web.tool notification, with "trigger": "call_end".
  • Filling the parameters from the conversation is part of the call's review, priced like the rest of it.

Best Practices

Write clear descriptions

The description field helps the AI understand when to use the tool. Be specific about what it does and when it's appropriate.

Handle errors gracefully

Return error messages the AI can understand: {"error": "No slots available for that date"} rather than generic 500 errors.

Keep responses concise

Return only what the AI needs to continue the conversation. A tool result stays in the conversation and is re-read on every later turn, so a large one adds cost and delay for the rest of the call. Results over 100,000 characters are cut down to a preview the AI knows is incomplete, and on a very long call older results may be dropped (the AI can call the tool again). Add a parameter so the AI can look up one item or category at a time, and put large reference content such as menus or catalogs in a knowledge base. Send Test Request in the old view shows each result's size and warns when it is large.

Use required fields wisely

Mark fields as required only when truly necessary. The AI will ask the user for required information before calling the tool.