A turn is one reply from your agent, and behind each reply there are one or more model calls, since every tool call is a model call too. So when a tool rejects a call and your agent retries it, you pay for another model call even though the reply count stays at one, and this guide counts both.
What you need
- Your agent connected to LangWatch, so the suite runs against your real code and the judge reads your traces.
- A test suite of five to ten scenarios that pass today. Take the situations from real conversations, and put the long ones in.
- Langy, or a coding agent with the
langwatchCLI installed andLANGWATCH_API_KEYset, so it can read the runs.
Step 1: Measure the baseline
Run the suite once against your agent as it is today and keep that run as the baseline:
langwatch test-suite run "Returns" --target connected:returns-agent --waitThe command prints the batch id, and the run header in LangWatch shows the pass rate, the total duration and the total cost. Hover the header for Avg Agent Latency and Avg Agent Cost with percentiles, and sort the table by Time · cost to see which conversations are the long ones.

Step 2: Get a hypothesis for improving the agent
Paste this into Langy or into your coding agent:
Reduce the number of turns my agent takes without failing any scenario.Use the langwatch CLI to read the last run of the last test suite I ran; ask me which one if it isnot clear from our conversation. Start from the longest conversations, tell me what causes theextra turns and the extra model calls, and make one change in the prompt, the tool descriptionsor the code for me to evaluate. Change nothing else.The agent comes back with a hypothesis, the conversations it found it in, and a change for it, which you test with the suite in the next step to prove the agent got better.
Most hypotheses come down to one of a few causes, and it helps to recognise them when you read the proposal:
- The tool rejects the input and the agent retries with different wording, because the tool description does not say which values it accepts. The fix is in the tool contract: see Fix tool calls.
- The agent asks the user for something a tool already returns, because the description does not say what the tool returns.
- The agent calls tools one per turn when the model could call them in parallel, or the prompt tells it to check one thing at a time.
- The agent narrates before it acts, spending a turn on "Let me check that for you".
- The iteration cap is high, so after a failed call the agent keeps trying instead of escalating or asking.
Step 3: Compare
Run the suite again with the changed agent next to the one you deployed, so both sides appear in one run over the same scenarios:
langwatch test-suite run "Returns" \ --target connected:returns-agent \ --target connected:returns-agent@production \ --waitThe run detail shows one column per target with its pass rate, total duration and cost, and four charts above them: Pass rate, Total cost, Average reply latency and Pass rate over runs. Keep the change when the pass rate holds or rises and the model calls per conversation went down. When a criterion fails on the changed side, read the judge's reasoning for the turn your agent skipped, and hand that back as the next prompt.
Be careful with the cost and the latency charts on a single pass: over six scenarios run once, both move more between two runs of the same agent than a removed retry moves them, so read those two from a run with --repeat 3.

To keep the gain, add a criterion that counts the replies, such as The agent completes the return within four replies. The judge counts the replies in the conversation and fails the scenario when your agent takes more.
Step 4: Keep it in CI
Run the suite on every pull request that touches the agent, so a later change cannot bring the turns back:
langwatch test-suite run "Returns" --target connected:returns-agent --waitThe command exits 1 when a scenario fails, which is what fails the job: see Run from CI.
Common failures
- The pass rate dropped. Revert the change and hand the judge's reasoning of the failed criterion to Langy or your coding agent: the reasoning quotes the turn where your agent stopped doing something it did before, such as confirming the refund method before it created the return.
- The turns did not move. The cause is in a tool rather than in the prompt: the agent keeps retrying because the tool still rejects the input, so fix the tool contract first.
- The judge reports
no agent spans arrivedand marks a criterion about the agent's behaviour inconclusive. The judge waits thirty seconds for the trace after the conversation ends, and under load the trace arrives later than that, so the judge reads an empty trace. Rerun the scenario. If the trace shows[REDACTED]for the tool names and contents instead, the data privacy policy of the project hides them from the judge as well: see Linking your traces. - The latency dropped and the cost did not. Your agent takes fewer turns but with longer prompts. Read the token count on the trace and shorten the context: see Reduce cost and latency.