A test plays one call in text: a simulated caller acts out scenario, the agent answers from its draft (instructions, first message and knowledge), and a judge checks the conversation against success_criteria. Write tests for the calls that matter, run them after each change, and publish when they pass.
curl https://evasay.com/api/v1/voice/agents/AGENT_ID/tests \
-X POST \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"name": "Move a booking",
"scenario": "A regular customer wants to move Friday 3 pm to Saturday morning.",
"success_criteria": "Offers Saturday times and confirms the new time and the customer'"'"'s name.",
"max_turns": 8
}'
POST /agents/{id}/test-runs runs all of the agent's tests, or those in test_ids, and answers with one run each (status: "running"). Poll GET /test-runs/{id} until status is passed, failed or error; the run then has the transcript and the judge's reason (in English, or Chinese with reason_language: "zh"). Each run costs Credits, shown with the tests in the dashboard; runs stop at the first the balance cannot pay for, and not_started lists the rest. A run that fails to play is refunded. Tests check what the agent says, not its voice or timing, and do not call its functions: preview those with POST /tools/{id}/test. An agent has up to 30 tests; PATCH and DELETE /agents/{id}/tests/{test_id} change or remove one.
Besides whole calls (type: "simulation", the default), a test can check one reply. type: "next_reply" takes chat_history, the conversation before it ending with the caller ([{role, text}], role being caller or agent), and success_criteria for the agent's next reply. type: "tool_call" takes chat_history and expected_tool {name, arguments, match}: the agent should call name (one of its functions, or end_call, transfer_call, handoff_to_agent) with arguments, compared exactly (text trimmed, case ignored) or, with match: "judge", by meaning; arguments it passes besides these are ignored. A run's transcript shows the functions the agent called in tool_calls.
POST /agents/{id}/tests/generate drafts tests from the agent's draft: its instructions, knowledge and functions. It takes count (1–10, default 5), types, focus (what to cover) and language (en or zh, for names and criteria), costs Credits like one run, and answers with drafts to review and send to POST /agents/{id}/tests; with save: true it saves them.