Set Up an AI Operator for a ServiceBeta
Add an AI Operator to a running Service to measure what it costs and how well it answers, then ask it for cheaper configurations.
About This Task
Before you start, make sure you have:
- A running Service you want to optimize.
- An Experiment for that Service's pipeline, with evaluators that judge answer quality. If the pipeline has no Experiment yet, the Add AI Operator modal tells you so and links to where you can create one.
Each Service can have only one AI Operator. If a Service already has a goal, it still appears in the Add AI Operator list, but it's disabled.
Add an AI Operator
- Go to Operate > AI Operator, or open a Service and click Set up AI Operator next to the actions menu.
- Click Add AI Operator.
- Select the running Service you want to optimize.
- Select the Experiment whose evaluators judge this Service's answers.
- Under Goal, select what to Optimize for. Optional: Set Min Quality score (0 to 1). A proposed configuration must always match the quality of the Service's current configuration. If you set a minimum, it must reach the current quality or your minimum, whichever is higher. Hover over the ? icon next to a label for details.
- Click Save to create the goal.
Result: The Service now has an AI Operator. Its row appears on the Operator list with a status based on its latest run, and the Service page shows an AI Operator button in place of Set up AI Operator.
View the Operator List
To check which Services are being optimized, whether each has a baseline, and when each was last measured, go to Operate > AI Operator. The list shows every optimization goal in the workspace. For each row, you see:
- Service: the Service the goal belongs to.
- Goal: the goal written as a sentence, so you can read what it keeps and what it optimizes for.
- Status: read from the latest measurement run (for example, whether a baseline exists or a run is in progress).
- Last run: when the Operator last measured the Service.
Click a row to open that Operator's page.
Measure a Baseline
Measure a baseline to record the Service's current cost, latency, and quality. You need a baseline before you can request suggestions, and it gives you numbers to compare them against.
A baseline run needs at least 9 Sessions (conversations). The AI Operator splits them 70/30 and holds out 30% to judge each suggestion, so 9 Sessions leave 3 held out. If the Service has fewer Sessions than the minimum, the run is refused. The same minimum applies when you run on a Dataset: the Dataset needs at least 9 test cases. A run with fewer than 50 Sessions is marked as a small sample, and its verdicts are less reliable.
- Open the Operator page for the Service, either from the Operator list or the Service page.
- Choose the pipeline version you want to measure.
- Start the measurement run. The Operator page switches to the new run so you can follow its progress.
- Review the baseline once the run finishes: cost, latency, and quality, along with the conversations the run used.To see each conversation's score labeled Training or Held out, or to score the baseline again, see Review and Re-Run Optimization Evaluations.
Inspect the Sessions the Baseline Is Replayed On
Before it measures anything, a measurement run replays the baseline on every test case that has at least one turn answered by another pipeline version or with no pipeline version recorded. A setup script on its own doesn't cause a replay. To check which sessions are replayed, or to compare what the baseline answered with what was recorded, open the replayed sessions from the run's progress.
- Open the Operator page for the Service and find the run in progress.
- In step 1 of the run progress, click the replay count (for example, Replaying the baseline on sessions from other versions: 3 of 11).
- In the Session inspector, select a session. To see what happened in the session, use the span tree and the span input and output view, which work the same way as for traces.
- Check the session's details: its ID, the version it was recorded on, and its status.
- Use the toggle to switch between As recorded and On the baseline. As recorded shows the turns of the original session. On the baseline shows the turns the baseline produced when it was replayed on that test case.
A session has one of these statuses:
- Waiting: the baseline hasn't been replayed on this session yet.
- Replayed: the baseline was replayed, and its turns are available under On the baseline.
- Could not replay: the replay failed, so the session has no baseline turns.
Result: You can see which sessions the baseline was replayed on and compare its answers with the recorded ones side by side.
If you work with the API, the sessions endpoint of a run (GET .../runs/{run_id}/sessions) returns baseline_session_id and baseline_query_ids for each replayed test case. baseline_session_id is the session the baseline produced, and baseline_query_ids lists that session's turns in replay order. The list is empty until the baseline has been replayed on the test case. The endpoint also returns replay_reason for each session: OTHER_VERSION when a turn was answered by a pipeline version other than the baseline's, NO_VERSION when a turn has no pipeline version, or null when the test case is measured as recorded.
View Past Runs
To compare what the Operator measured and suggested over time, or to look back at an earlier run, use the Runs table on the Operator page. The table lists every run of the Service's Operator, newest first. It appears once the Service has two or more runs.
For each run, the table shows:
- Started: when the run started. Hover over the time to see the exact date. The newest run has a Latest tag, and the run currently shown on the page has a Viewing tag.
- Version: the pipeline version the run measured. If the version isn't known, the table shows a placeholder instead.
- Conversations: which conversations the run measured: sampled, hand-picked, or from a dataset.
- Tested: how many configurations the run tested out of the maximum, for example "2 of 3 configurations".
- Result: how the run ended. One of Running, Found an improvement, No improvement, Inconclusive, Stopped, or Failed.
The table shows 10 runs at first. To load 10 more, click Show older runs.
You can open an earlier run by clicking it in the Runs table.
Fix a Refused Run
An AI Operator run can be refused when some of the Sessions it would use can't be replayed, or when too few Sessions remain. The error message names each affected Session by its name and its id, in the format '<name>' (<session id>). Several Sessions can share a name because a name is usually the Session's first query. Use the id to tell them apart.
Typical reasons for a refusal include:
- A Session has turns that recorded no inputs because content tracing was off, so its requests can't be replayed.
- A Session was recorded on a different pipeline from the one the Service runs.
- Too many Sessions failed when the baseline was replayed on them.
- Too few Sessions are left to hold out some for judging a candidate. This can happen when recent traffic is used and Sessions are dropped because they recorded no inputs.
To fix a refused run:
- Read the error message and note the Session ids it lists.
- On the Operator page, check the run's Left out list. The Session column names each Session, and the Why column gives the reason it was left out.
- Remove the Session from the Dataset, or fix the cause (for example, turn on content tracing for the Service so new Sessions record their inputs).
- Start the run again. If the run is refused again, repeat these steps for the Sessions the new error message lists.
If you start runs through the API, a refused Dataset run returns a 422 response. Besides errors and test_case_ids, the response lists the affected Sessions in session_ids. Other refusals, such as too many Sessions that couldn't be replayed or too few Sessions left, name each left-out Session by name and id in the error message only. Use these ids to find the Sessions and their traces. To learn where to view traces, see Trace with Built-In Traces.
Review Suggestions
Once a baseline exists, you can ask the AI Operator for optimization suggestions:
- On the Operator page, request suggestions.
- Review each suggested configuration together with its validated cost and quality.
- Copy a suggestion's configuration if you want to try it yourself. The AI Operator does not apply or promote any suggestion automatically — you decide what to do with it.
To act on a suggestion from the latest run, click Accept to roll out its configuration, or click Decline to dismiss it. You can accept or decline suggestions only for the latest run. Suggestions from earlier runs are read-only.
If a suggestion's scoring failed or expired, or you want every conversation judged again, click Re-run evaluation on its card. For details, see Review and Re-Run Optimization Evaluations.
Edit or Remove the Goal
On the Operator page, you can:
- Edit the goal to change what to Optimize for or the Min Quality score. You can't change the Experiment after you create the goal. Saving a goal that previously allowed some quality loss resets that allowance to zero, so proposed configurations must match the baseline's quality.
- Remove the goal, which also removes the Service from the Operator list.
What To Do Next
- AI Operator explains the concepts behind goals, baselines, and suggestions.
- Run an Experiment to learn more about the evaluators an AI Operator relies on.
- View Cost and Quality Trends on the AI Operator Page to see how the Service's cost and quality change across releases.
Was this page helpful?