Skip to main content
Route new calls across managed agent versions to compare changes with production traffic. Traffic allocation does not change the published version, and calls already in progress stay on the version selected when they started.

Before you start

Create a custom metric for the outcome you want to compare. Assign the metric before you start the test so Cartesia evaluates calls from every version. You also need at least two versions of the same managed agent. Publish a change in the Playground or update the agent to create a version. Then list the agent’s versions and copy their id values. You do not need to deploy managed versions before you add them to an allocation.

Split traffic between versions

Call PUT /agents/{agent_id}/traffic-allocation with one to five unique version IDs. Percentages can use up to two decimal places and must total 100. Each successful PUT creates an immutable allocation revision. New calls use the latest revision. To inspect it, call GET /agents/{agent_id}/traffic-allocation.

Choose how phone calls are assigned

Set assignment_strategy based on how you want phone calls to reach the versions in your traffic split:
  • sticky_by_caller keeps an external phone number on the same version while the traffic split stays the same. Cartesia uses the caller number for inbound calls and the destination number for outbound calls. This is the default.
  • random_per_call assigns each new phone call separately. Calls from the same phone number can reach different versions, which helps when you test with only a few phone numbers.
Web calls that use traffic allocation are always assigned per call, so assignment_strategy does not affect them. When you create an allocation, omitting assignment_strategy uses sticky_by_caller. When you replace an active allocation, omitting the field preserves its current strategy. Set the field explicitly when you want to change strategies.

Supply variables for every version

Cartesia validates dynamic variables after it selects a version for a web session or batch recipient. If the selected version’s initial message needs a missing value, the web session ends or the batch recipient fails with error_code: missing_dynamic_variables. Supply the variables required by every version in the allocation. See Dynamic variables for request examples.

Move a change from staging to production

  1. Use Preview to test the draft without changing live calls.
  2. Before publishing the candidate, set the current production version to 100 percent in the traffic allocation.
  3. Publish the candidate, then update the allocation to send it a small percentage of live calls.
  4. Compare the results. Move the candidate to 100 percent if it wins, or return the production version to 100 percent.

Compare results

GET /agents/calls returns the selected agent_version_id and the traffic_allocation_id used for each call. Group calls by agent_version_id, then use each call’s ID to compare its metric results.
The allocation ID identifies the exact immutable revision. Use GET /agents/{agent_id}/traffic-allocations to retrieve the targets and percentages for earlier revisions.

Change or end a test

Send another PUT request to change the percentages. To keep the winning version in use as you publish new versions, set its percentage to 100 and leave the allocation active. New versions receive no traffic until you update or clear the allocation. To return to the default routing behavior, call DELETE /agents/{agent_id}/traffic-allocation. New calls then use the latest published version, including any versions that you publish later. If the winning version is older, you can make it the published default before clearing the allocation. Get that version and pass its config to Update Agent. The update creates a new published version. Clearing an allocation does not delete its history. It records an empty revision, and the current-allocation endpoint returns 404 until you create another allocation.

What to test

Versions capture the agent’s instructions, model, voice, language, and other versioned configuration. Change one behavior at a time when you need to attribute a result to a specific change. Versions store references to shared resources such as tools. Editing a shared tool can affect every version that references it. To test tool behavior in isolation, create a separate tool and attach it to the variant.