Skip to main content

Get started

In this tutorial, you’ll use Patterns to find costly behavior in sample support conversations, test whether a cheaper model can handle those requests, then have Loop propose a code change for your coding agent to review. You’ll need:

Set up the project

You’ll work with 600 simulated support conversations, spread over the last two weeks, in which customers ask an agent to change flights, return orders, or fix phone service. Each conversation is a trace with the agent’s model and tool calls, a task success score, and metadata about the customer, model, agent version, and cost.
1

Import the sample conversations

Download the sample importer and the sample data (about 130 MB), then import the conversations into a new project called Sample - Support agent - tutorial:
Replace <your-org> with your organization name. The import should report 600 traces and 20,239 spans.
2

Check the imported traces

Open Logs and confirm that the conversations appear with their model and tool calls.
Logs page for the Sample - Support agent - tutorial project, listing imported support-agent traces with their input, output, task_success score, and duration.
An imported support-agent trace open in Logs, showing its LLM and tool call spans in the tree and the conversation in the Thread tab.
3

Set the user and session ID fields

Ask Loop or your coding agent to set the project’s user and session ID fields, so Patterns counts affected users and sessions instead of individual traces:
Run in Loop
4

Connect the agent's code

Loop needs a copy of the agent’s code so it can cite the code in findings and open a pull request with a fix. Connect it before you enable Patterns, so discovery can include code evidence.
  1. Create a fork of the sample support-agent repository.
  2. Connect GitHub and give Loop access to your fork.
  3. Connect the fork to your project, and allow Loop to create pull requests.
GitHub installation settings in Braintrust Integrations, with Use this installation and Allow Loop to create PRs turned on, and the forked patterns-demo-support-agent repository listed.
5

Enable Patterns

Enable Patterns. Optionally connect Slack and select a channel for alerts.
Patterns setup panel with a Continue button.Patterns Slack alert setup with a channel selector and an option to enable without Slack alerting.
Wait for the first discovery run to finish, which can take 30 minutes or more.

Find a problem

Patterns uses Loop to investigate your traces on a schedule and report recurring problems. Each finding, called a pattern, has a severity, a count of the users or sessions it affects, and the traces that show it. With a connected repository, a pattern can also cite the code involved. In this section, you’ll review a pattern, then focus the discovery rule on cost to find a model that’s more expensive than it needs to be. Findings and their titles vary between runs. See Review and act on patterns for everything a pattern includes.
1

Scan the Patterns list

Open Patterns. Each row is a recurring problem with its severity, summary, categories, and when it was first and last seen.Because you set the user ID field, the counts show how many distinct customers each pattern affects instead of how many traces. A problem that appears in 300 traces might come from a single customer. Compare severity and affected users to decide which pattern to open first.
Patterns list for the Sample - Support agent - tutorial project, showing patterns with severity, affected users, categories, and first and last seen times.
2

Examine a pattern

Open a pattern and read its summary. Below its name, check how widespread it is: the share of traffic it affects and when it was measured. A ~ marks an estimate from a sample.Open a supporting trace and inspect the highlighted evidence. If the pattern includes code evidence, use the Code tab to review the cited implementation. Check that the evidence supports the pattern.
A pattern report showing 50 affected users, its properties, an impacted users chart, and its summary, next to a supporting trace with the evidence highlighted in the input.
3

Add a cost concern

To focus on cost, open Pattern discovery from the rules menu. Under Watch for, add:
Under Custom instructions, enter:
Click Save and then Run now.Pattern rule editor for Pattern discovery, with the expensive-models concern under Watch for, the cost instructions under Custom instructions, and the Run now and Save buttons.
4

Find a cost pattern

The run can take a while. To follow its progress, open the rules menu in the page header and click next to Pattern discovery. Loop’s thread for the run opens in a new tab, where you can watch the searches it runs and the traces it reads.When the run finishes, look for a new pattern in the Cost category. A cost pattern describes money spent without a better result, such as one model accounting for a large share of spend on a small share of conversations.Open the pattern and check its evidence:
  • Summary: Names the expensive model, the agent version, the requests involved, and the cost difference, measured from metadata.cost_usd.
  • Models: If the breakdown is available, compare each model’s share of matches with its share of all traffic. If an expensive model’s share of matches is much higher than its share of traffic, that model is driving the cost.
  • Evidence: Open a few supporting traces and confirm the model, agent version, cost, and task_success score in each.
  • Failed calls: Failed or retried model calls raise a conversation’s cost, so a cost gap can reflect errors rather than model pricing.
A Cost pattern named Opus drives support spend in Claude Code, affecting 26 users, with its summary and an evidence trace showing Claude Opus 4.5 model calls and a $2.53 estimated cost.

Compare models

The cost pattern gives you a hypothesis: a cheaper model could handle the same requests. An eval tests that hypothesis on a fixed set of cases.
1

Build a baseline eval

With the cost pattern open, click Loop agent at the bottom right. Loop attaches the pattern automatically. Paste this prompt to build a baseline:
2

Run the baseline

In the conversation, review the cases and scoring criteria Loop proposes. To see every case, open the Model cost comparison dataset in Datasets, and compare a few cases with their source traces. When they look right, ask Loop to run the baseline:
When the run finishes, Loop summarizes the results in the conversation. To inspect individual cases and their scores, open the experiment from the link Loop provides.
Loop conversation summarizing the Claude Opus 4.5 baseline: 4 of 4 cases passed, with estimated generation cost, cost per successful case, and a table of the dataset version, model, scorer, and token usage.
3

Compare a cheaper model

In the same conversation, ask Loop to compare a cheaper model:
4

Review the comparison

Read Loop’s comparison in the conversation, which lists the cases where the models differ. To check a disagreement, open the case in the experiment and read the scorer’s explanation.
Loop conversation comparing the Opus 4.5 baseline with the GPT-5.2 experiment: equal saved quality scores, lower estimated cost for GPT-5.2, and one case where GPT-5.2 skipped a required tool call.
If the cheaper model’s quality is close to the baseline’s at a lower cost per successful case, continue to Make and verify the change, where Loop updates the agent to send these requests to the cheaper model. If quality drops more than you can accept, investigate the failing cases before changing the agent.

Make and verify the change

Loop turns the eval result into a pull request in your fork that sends those requests to the cheaper model. Before you merge, your coding agent reviews it against the original traces.
1

Open a pull request with Loop

Continue in the same Loop conversation:
2

Review the pull request with your coding agent

Clone your fork and check out the pull request’s branch:
In the pattern’s header, select Investigate > Copy as prompt. Paste the brief into your coding agent in your local clone, along with the PR and experiment links. Ask it to review:
3

Test before merging

Address the blocking issues from the review and run the changed agent on representative conversations before merging. Check task outcomes, the model recorded in new traces, and total cost, including fallbacks.The new traces should show which requests used the cheaper model and whether they succeeded. If they still use the original model, inspect the routing and fallback behavior before claiming savings.

Close the loop

Your rating and notes on the pattern tell Loop and your teammates what you did about it.
1

Rate the pattern

Under Is this pattern useful?, click Yes or No, add a reason, and click Submit. Yes lets Loop reopen the pattern if the behavior returns after it closes. No closes the pattern and tells Loop not to reopen or recreate a matching pattern while your reason still applies.
2

Link the pull request

In the pattern’s Activity, add a comment with the PR link so teammates can follow the work. Mention a teammate to notify them.
After you deploy the fix, new traces from the updated agent show whether the behavior stopped. Scheduled runs close patterns whose behavior has stopped and reopen them if it returns, with a Slack alert if you set one up.

Next steps

Apply the workflow to your own agent: add tracing, use Patterns to identify a problem, and build an eval to test a change.

Explore more capabilities

Build on the tutorial with Loop, playgrounds, human review, and evals in CI.