Skip to main content

Agent Studio test cases are simulated conversations that run your agent end-to-end in the sandbox environment. They are managed locally as YAML files under test_suite/ and pushed to Agent Studio with poly push.

Each test case describes a scenario for a simulated user and a set of assertions to evaluate against the resulting conversation. Then, the tests run inside Agent Studio against the pushed branch.

Where tests fit in the workflow

Tests sit between validation and merge in the standard CLI working pattern. Edit locally, validate with poly validate, push, then trigger and inspect the test suite with poly test.

Validation

Use poly validate to check project configuration before pushing.

Simulated conversations

Define test cases under test_suite/ and run them with poly test run.

Interactive review

Use poly chat, poly test show, and Agent Studio to spot-check behavior on the pushed branch.

Location

Test cases are defined as one YAML file per test under:
The directory is optional. Create it only when you have test cases to define.
Filename must match the test nameThe filename (without .yaml) must match the normalized form of the name field: lowercased, with punctuation replaced by underscores. Greeting flow test becomes greeting_flow_test.yaml. poly push rejects mismatched names.

What a test case contains

At least one of prompt_assertions or function_call_assertions should be set — a test with no assertions runs but cannot pass or fail.

Test clock

simulated_at pins the agent’s notion of “now” for the duration of the simulated conversation. Use it to make time-dependent behavior deterministic — out-of-hours routing, “tomorrow” date resolution, or a seasonal greeting — instead of depending on when the suite happens to run.
Values are parsed as ISO 8601 and normalized to UTC when written back by poly pull, so 2026-01-15T22:30:00+00:00 and 2026-01-15T23:30:00+01:00 both round-trip as 2026-01-15T22:30:00Z. An offset-less value such as 2026-01-15T22:30:00 is treated as UTC. Omit the field to run against the real clock; removing it from a file that had one clears the test clock on the next push.

Mock call context

A real conversation arrives carrying more than the caller’s words: the number it came from, the SIP headers a carrier attached, the attributes a channel passed in. Three optional fields simulate that, so a flow that branches on any of it can be tested without placing a real call.

caller_number

The number the call arrives from, always text. The agent reads it as conv.caller_number. Leave it out to simulate a withheld or anonymous number — a real production case worth testing, so no format validation is applied beyond trimming whitespace. Quote it. YAML reads an unquoted number as an integer and drops a leading +:
poly push rejects an unquoted number rather than converting it, because the two cases are indistinguishable once YAML has parsed them and silently sending a different number would make the test lie.

sip_headers

Headers a carrier would send with an inbound call. The agent reads them as conv.sip_headers. Header names are case-sensitive — match exactly what your telephony integration sends. Values are always text on the wire, so a YAML true is sent as "true" and a number as its digits. Quote anything you want preserved exactly. Headers can be set on a webchat test, but a real webchat conversation never receives them, so the test would cover a state production cannot reach.

integration_attributes

Attributes a channel or connector passes in. The agent reads them as conv.integration_attributes. Unlike SIP headers, these keep their type, so a flow branching on retry_count > 2 sees a number rather than the text "2". Text, numbers, true/false, null, lists, and nested maps are all supported. Types come from YAML, which means quoting matters: Dates must be quoted. An unquoted expiry: 2026-08-12 is a YAML date, which the agent cannot receive, and poly push rejects it rather than guessing what you meant.

Mock agent memory

agent_memory sets the Agent Memory profile the agent sees, read as conv.memory, so returning-caller and first-time-caller paths each get a test case of their own. When it is set, it replaces conv.memory for the whole run, and nothing stored for the caller is read.
There are three states, and each one means something different: A flow that branches on conv.memory wants both a returning-caller case and a first-time-caller case. caller_number alone doesn’t make a returning caller, so use agent_memory for that. Values follow the same type rules as integration_attributes: they keep their YAML type, nested maps and lists are supported, and dates must be quoted. Use synthetic values only, never real customer data. Pulling, renaming and pushing a case keep {} and an absent field distinct.

API mocks

A flow that branches on an API integration’s response — a booking that’s available vs. full, a lookup that succeeds vs. errors — needs that response to be deterministic to test reliably. api_mocks intercepts calls to a named integration operation during simulation and returns the mocked response instead of calling the real API. Mocks are keyed by integration name, then operation name, then a list of response rules tried in order:
Each rule has: Once a list’s rules are exhausted (no trailing -1 rule), further calls to that operation fall through to the real API.
Operation names aren’t cross-checked at push timeThe integration name must match an existing api_integration resource; poly push rejects an unknown one. Operation names are not validated against the integration’s configured operations — instead, renaming or deleting the underlying operation automatically cascades to any mocks that reference it, the same way the platform handles the rest of the integration/operations relationship.

Prompt assertions

Each prompt assertion is a free-text statement evaluated against the full conversation by an LLM judge. Write them as observable behaviors, not internal reasoning.

Function call assertions

Each function call assertion checks that a function was called and, optionally, with specific argument values. Argument assertion fields:
Only function name and argument values are asserted. The function does not have to be the only call in the conversation, and the order of calls is not checked.

Example

A minimal webchat smoke test with only a prompt assertion:

Validation

poly validate checks each test case:
  • channel must be voice or webchat
  • scenario is required and non-empty
  • tags must be unique
  • language is required and must be one of the project’s configured languages (default_language or additional_languages)
  • variant, if set, must reference a variant declared in config/variant_attributes.yaml
  • simulated_at, if set, must be a valid ISO 8601 datetime
  • caller_number, if set, must be text — an unquoted number is rejected rather than converted
  • integration_attributes values must be text, numbers, true/false, null, lists, or nested maps; an unquoted date is rejected with the quoted form to use instead; keys must be text
  • agent_memory, if set, must be a map; its values follow the same type rules as integration_attributes
  • api_mocks: the integration name must match an existing api_integration resource; each operation must have at least one response rule; each rule’s respond.status must be a valid HTTP status code (100–599); respond.body, if set, follows the same type rules as integration_attributes; repeat, if set, must be a positive integer or -1 (respond forever), and -1 is only allowed on the last rule for an operation
  • each function_call_assertions[*].name must match a global function under functions/ or a flow function under flows/<flow>/functions/
  • each argument’s value_type must be one of string, integer, float, boolean
  • each argument’s expected_value, when set, must not be blank and must read as its value_type
  • the filename must match the normalized name
Validation runs automatically as part of poly push.

Push and run

Test cases follow the standard ADK lifecycle:
  1. edit YAML files under test_suite/ locally
  2. validate with poly validate
  3. push with poly push to sync to Agent Studio
  4. trigger and monitor the suite with poly test run
poly push creates, updates, or deletes test cases on Agent Studio to match local state, including prompt_assertions and tags. Use poly test run to trigger execution and poly test show / poly test list to inspect results — all without leaving the terminal. See poly test for the commands and their flags.
Tests are branch-scopedTests are pushed to the current branch and run against that branch’s agent. Use a branch per scenario when iterating on flows or topics so test results map cleanly to the change under review.

What to cover

Good coverage of a project usually includes:
  • the happy path of every flow and major topic
  • key error paths — missing booking, invalid input, unavailable slot
  • function call shape — confirm the agent calls the right function with the right arguments for each branch of logic
  • state transitions across turns — confirm later turns reference earlier user input
  • behavior on the channels your project actually ships on (voice, webchat, or both)

Best practices

  • write scenario as a short, concrete user goal — “Ask to cancel a booking with reference ABC123” — not a script
  • prefer prompt assertions for behavior, function call assertions for integration correctness
  • keep each test case focused on one outcome; split combined scenarios into multiple files
  • use tags consistently (smoke, regression, <flow_name>) so suites can be filtered with --tag
  • cover error paths, not only success cases
  • add a webchat and a voice variant of any critical path that runs on both channels
  • validate as part of the normal edit loop, not just before merge
  • combine the suite with poly chat and interactive review in Agent Studio when behavior depends on the full conversation flow

CLI reference

poly validate, poly push, poly chat, and poly test — the commands used in the test workflow.

Functions

Reference for the functions named in function call assertions.

API integrations

Define the integrations and operations that api_mocks intercepts.

Variants

Define the variants referenced by the variant field.

Languages

Configure the languages a test case can target.

Working locally

How tests fit into the daily edit / validate / push loop.
Last modified on November 27, 2026