Skip to navigation

Release client tool changes

Pin each frontend release to an agent version, and ship breaking client tool changes without breaking apps that are already deployed

A client tool has two halves that ship separately. The tool’s definition lives on the server and is pushed from the SDK or the dashboard. Its handler lives in your frontend and reaches users only when they load a new release. This guide shows how to keep the two in step: each frontend release starts conversations on the agent version it was built against, and a breaking change to a tool ships as a new tool alongside the old one.

How a tool change reaches deployed clients

Agents are versioned. Tools aren’t. A version records which tools an agent uses by their IDs, but a tool’s definition, including its name and parameters, is stored on the tool and shared by every agent, branch and version that uses it. Updating a tool changes it everywhere at once. Editing tools safely describes this in detail.

This has two consequences for client tools:

  • agents.push() updates a changed tool in place, so its new definition reaches every deployed copy of your frontend, including releases that only have the old handler. This happens even when you push to a branch.
  • Pinning a frontend to an agent version protects it from changes to the agent’s prompt, settings and attached tools, but not from changes to a tool’s definition.

Treat a client tool that a released frontend uses as fixed. Make backward-compatible changes in place, and ship a breaking change as a new tool with a new name.

Decide whether a change is breaking

A change is breaking if a handler that is already deployed can’t handle what the agent now sends, or doesn’t return what the agent now expects.

ChangeBreakingHow to ship it
Add an optional parameterNoPush in place, then release the updated handler.
Reword the tool’s or a parameter’s descriptionNoPush in place. It changes when the LLM calls it.
Rename or remove a parameterYesNew tool
Make a parameter required, change its type, or narrow its allowed valuesYesNew tool
Change expects_response, or what the agent expects the handler to returnYesNew tool
Rename the toolYesNew tool

An added optional parameter is safe only if existing handlers ignore parameters they don’t know. Handlers in the JavaScript and React SDKs receive the parameters as a single object, so extra keys are ignored unless your code rejects them.

Pin each frontend release to an agent version

Pin every release, not only the one that introduces a breaking change. A release that starts conversations on the main branch moves to whatever main becomes, including a later merge that removes the tool it handles.

1

Push the agent and record its version

After agents.push(), read the agent’s current version and write it to a file that ships with the frontend build. Run this in the same deploy job as the push, so that no other push lands in between:

import json
from elevenlabs import ElevenLabs
from elevenlabs.agent_builder import Agent
from elevenlabs.agent_tools import Schema, Tool
AGENT_ID = "agent_7101k5zvyjhmfg983brhmhkd98n6"
elevenlabs = ElevenLabs()
add_to_cart = (
Tool.client("add_to_cart", "Add a product to the shopper's cart")
.param("sku", Schema.string().describe("The product SKU, e.g. TSH-0042"))
.options(expects_response=True)
)
agent = Agent(
"Kiosk assistant",
prompt="You help shoppers find products and add them to their cart.",
tools=[add_to_cart],
)
elevenlabs.conversational_ai.agents.push(agent, agent_id=AGENT_ID)
pushed = elevenlabs.conversational_ai.agents.get(agent_id=AGENT_ID)
with open("web/src/agent-release.json", "w") as f:
json.dump({"versionId": pushed.version_id}, f)

The version ID, such as agtvrsn_3901k6kz2c4ep8vm7tq5hd1xw9fb, identifies a fixed snapshot of the agent. Later pushes create new versions and leave this one as it is.

2

Mint conversation tokens for that version

Pin the version on your server, where you create the conversation token or signed URL. Both accept version_id. The client SDKs accept a branchId when they start a session, but not a version ID.

The frontend sends the version it was built with, and the server only accepts versions you have released. Without that check, a client could start a conversation on any version of the agent, including one on an unreleased branch:

import os
from elevenlabs import ElevenLabs
AGENT_ID = "agent_7101k5zvyjhmfg983brhmhkd98n6"
# For example "agtvrsn_3901k6kz2c4ep8vm7tq5hd1xw9fb,agtvrsn_5201k7p4m9wcx3rd8ht2vq6ne1sa"
RELEASED_VERSIONS = set(os.environ["RELEASED_AGENT_VERSIONS"].split(","))
elevenlabs = ElevenLabs()
def conversation_token(version_id: str) -> str:
if version_id not in RELEASED_VERSIONS:
raise ValueError(f"Unknown agent version: {version_id}")
response = elevenlabs.conversational_ai.conversations.get_webrtc_token(
agent_id=AGENT_ID,
version_id=version_id,
)
return response.token

Keep the agent ID on the server, so that a client can only choose between versions of your agent.

3

Start sessions from the frontend with the token

The frontend sends the version from its build to your server, starts the session with the token it gets back, and registers a handler for each client tool that version uses. onUnhandledClientToolCall reports a call the release has no handler for. The SDK already returns an error to the agent for such a call, so the callback only needs to log it:

import { useConversation } from "@elevenlabs/react";
import release from "./agent-release.json";
import { cart } from "./cart";
export function useKioskConversation() {
const conversation = useConversation({
clientTools: {
add_to_cart: async ({ sku }: { sku: string }) => {
cart.add(sku);
return { items: cart.size };
},
},
onUnhandledClientToolCall: (call) => {
console.error(`No handler for client tool ${call.tool_name}`);
},
});
async function start() {
const response = await fetch(
`/api/conversation-token?version_id=${encodeURIComponent(release.versionId)}`
);
const conversationToken = await response.text();
await conversation.startSession({ conversationToken });
}
return { conversation, start };
}

Add the release’s version to RELEASED_AGENT_VERSIONS before you deploy the frontend, and remove a version once no deployed release uses it.

Ship a breaking change as a new tool

Give the changed tool a new name, push it to a branch, and release a frontend pinned to that branch’s version. Releases that are already deployed stay pinned to their own version, which still uses the old tool.

1

Define the tool under a new name

push() matches tools by name, so a new name creates a new tool and leaves the old one unchanged. This version of add_to_cart adds a required quantity parameter:

add_to_cart_v2 = (
Tool.client("add_to_cart_v2", "Add a product to the shopper's cart")
.param("sku", Schema.string().describe("The product SKU, e.g. TSH-0042"))
.param("quantity", Schema.integer().describe("How many to add"))
.options(expects_response=True)
)
agent = Agent(
"Kiosk assistant",
prompt="You help shoppers find products and add them to their cart.",
tools=[add_to_cart_v2],
)

With the Python @client_tool decorator, pass @client_tool(name="add_to_cart_v2") to keep the function’s name. If the agent’s prompt mentions the tool by name, update the prompt as well.

2

Push it to a branch

Create a branch from the main branch’s current version and push the agent to it. On the branch, push() creates add_to_cart_v2 and reports add_to_cart as "detached". The main branch still uses add_to_cart:

main = elevenlabs.conversational_ai.agents.get(agent_id=AGENT_ID)
branch = elevenlabs.conversational_ai.agents.branches.create(
agent_id=AGENT_ID,
parent_version_id=main.version_id,
name="add-to-cart-quantity",
description="add_to_cart_v2 takes a required quantity",
)
elevenlabs.conversational_ai.agents.push(
agent,
agent_id=AGENT_ID,
branch_id=branch.created_branch_id,
)
pushed = elevenlabs.conversational_ai.agents.get(
agent_id=AGENT_ID,
branch_id=branch.created_branch_id,
)
with open("web/src/agent-release.json", "w") as f:
json.dump({"versionId": pushed.version_id}, f)

Test the branch before you release it. Test a tool change without affecting production covers running tests against a branch and mocking tools.

3

Release the frontend with the new handler

Register add_to_cart_v2 in the release built against the branch’s version. Add that version to RELEASED_AGENT_VERSIONS, then deploy the frontend. Clients that load the new release start conversations on the branch’s version, and clients still on the old release keep using add_to_cart.

Don’t route clients to the new version with a traffic deployment. A deployment splits conversations between branches by conversation ID, not by frontend release, so it would send old clients to a version that calls a tool they can’t handle.

4

Merge the branch and retire the old tool

Merge the branch into main when the release is out, so that main, and anything that starts conversations without a pin, uses add_to_cart_v2. Merging branches covers previewing and running the merge.

Keep the add_to_cart tool until no deployed release is pinned to a version that uses it. Those versions reference the tool by ID, so deleting it breaks the releases that still use them. Before you delete it, check what still uses it, and remove the old versions from RELEASED_AGENT_VERSIONS.

Check handlers against the agent

In Python, tools.check_client_tools() compares @client_tool functions with the client tools on the agent’s main branch. It reports each function the agent has no tool for, and each parameter that differs. Run it with strict=True in CI to stop a release whose handlers don’t match the agent. The JavaScript SDK has no equivalent yet.

Next steps