Release client tool changes
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.
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.
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:
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.
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:
Keep the agent ID on the server, so that a client can only choose between versions of your agent.
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:
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.
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:
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.
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:
Test the branch before you release it. Test a tool change without affecting production covers running tests against a branch and mocking tools.
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.
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.