Evaluations that lead to decisions, Part 2: golden datasets, sampling, cost and continuous improvement for AI agents on Amazon Bedrock AgentCore
The second part of the series turns a short list of evaluators into a working system. Learn how to start without a golden dataset and grow it from production failures, how to set the sampling rate for online evaluation with a ready-to-use lookup table, what drives evaluation cost, and how to keep it all improving as a routine with Amazon Bedrock AgentCore Evaluations.
Series: Evaluations that lead to decisions (2 articles)
- 2Evaluations that lead to decisions, Part 2: golden datasets, sampling, cost and continuous improvement for AI agents on Amazon Bedrock AgentCore This article
A two-part series. Evaluating AI agents well is an important topic, and a large one. It covers what to measure, how to check it, when to run each check, how far to trust the scores, what they cost, and how to keep the whole system relevant over time. All of this doesn't fit into a single post on this platform because of its length limit, so we have split it into two parts that build on each other:
- Part 1 : the core rule that turns scores into decisions, what to measure, how to check it, and the three loops in which you evaluate.
- Part 2 (this post): golden datasets (starting without one, and growing it from production failures), how to set the sampling rate for online evaluation, what drives cost, and how to keep improving.
If you haven't read Part 1 yet, we recommend starting there. If you're short on time, the recap below gives you what you need to follow this post.
What you will learn in Part 2:
- how to start without a golden dataset, evaluate a model upgrade, and keep the golden dataset relevant as failures turn into new test cases
- how to set the sampling rate of online evaluation in a principled, statistical way, with a ready-to-use lookup table
- what drives evaluation cost, and how to keep it working as a routine
Contents (Part 2)
A quick recap of Part 1
Part 1 started from one idea: an evaluation is only worth running if it can change a decision: what to release, what to fix, whether to adopt a new model, and what to stop paying for. Before adding any evaluator, ask: "If this score drops, what exactly will we change?" If there's no answer, don't add it.
The framework answers five questions in order. Part 1 covered the first two and introduced the third; this post completes the third and covers the last two.

- 1 · What to measure: start from one sentence of business success, break it into quality dimensions, and measure what the agent delivers (an action or an artifact), not just what it says.
- 2 · How to check it: climb the method ladder only as far as you need: prevent the failure inside the agent, then code checks for anything exact, then built-in or custom LLM judges, calibrated against your own labels.
- 3 · When and where: in three loops. The inner loop while building (AgentCore on-demand evaluation), the outer loop before each release, with a small smoke set on every change and the full golden dataset on every release (on-demand and batch), and the production loop, which scores a sample of live sessions (online evaluation). Ground truth exists only in the first two.
The running example. As in Part 1 , we use a fictional invoice-processing agent. It reads a supplier invoice, extracts the fields, matches the invoice to a purchase order, applies the approval policy, and either posts it to the finance system or escalates it to a person. Its quality dimensions include D1 "fields match the schema", D2 "approval policy respected", D3 "totals reconcile", D4 "escalates when it should", D5 "right decisions, honest reporting", D6 "posted data correct end to end" and D7 "efficient".
Terms used in this post
The same terms as in Part 1 , each used with exactly one meaning. Section 7 adds a few statistics terms.
Term | Plain-language meaning |
|---|---|
Session | One end-to-end request to the agent, e.g. processing one invoice |
Trace | One turn or agent step inside a session, e.g. the extraction step |
Tool call | A single tool invocation inside a trace, e.g. "look up purchase order" |
Evaluator | Anything that scores a session, trace or tool call: returns a score, a label and an explanation |
Code check | An evaluator written as ordinary code (in AgentCore: a code-based evaluator on AWS Lambda). Exact and cheap |
LLM judge | An evaluator in which a language model grades the agent against a rubric. Flexible, but its verdicts vary |
Ground truth | The known correct outcome for a test case you prepared. Live production sessions have none |
Test case | A prepared input plus its ground truth |
Golden dataset | Your curated collection of test cases, used to test every change and release |
Quality dimension | One part of what "success" means for your agent, e.g. "totals reconcile" |
6. When and where to evaluate (continued)
Part 1 introduced the three loops in which you evaluate: the inner loop while building, the outer loop before each release, and the production loop after release. Ground truth exists only in the first two, for the test cases you prepared. This section picks up from there.
6.2 No golden dataset yet? Start with parity
The outer loop assumes you have ground truth. Many teams don't have a golden dataset yet, especially when a first version is already running. You don't need to wait: use your current version as a provisional reference. Run real inputs, for example recorded production sessions with sensitive data masked, through both the version you have today (the baseline) and the version you want to ship (the candidate: a new prompt, tool or model), and compare.

Be clear about what this measures: parity, not correctness. Agreement only tells you the candidate behaves like the baseline; if both are wrong in the same way, the comparison can't see it. So:
- Review every disagreement and label the correct outcome: these become test cases in your golden dataset.
- Spot-check a sample of agreements, because shared mistakes hide there.
- Keep running evaluators that need no ground truth, such as code checks and faithfulness, to catch errors both versions share.
This is also the natural way to evaluate a model upgrade before you have a full golden dataset. Over time, the labelled disagreements and the production failures (section 6.3) become your golden dataset, and parity gives way to real correctness checks. In AgentCore, score both versions' sessions with the same evaluators in batch evaluation, or compare them with the A/B tests in AgentCore's optimization capabilities ( announcement ). To run a new version in shadow mode against production traffic, see Evaluating AI agents: a production blueprint with Strands and AgentCore .
6.3 Today's failures are tomorrow's golden dataset
In the three loops from Part 1 , every production failure becomes a new test case for the outer loop. That arrow, going back from production to the outer loop, is the most important one in the framework.
A golden dataset written before launch reflects what the team imagined could go wrong; production shows what actually goes wrong. Fix a failure without adding a test case, and nothing stops it returning after the next prompt change or model upgrade. Add the test case, and the outer loop catches it in every release from then on. The AWS DevOps Agent team describes the same practice in From AI agent prototype to product .
The failure lifecycle:

Write the test before you trust the fix. A test that fails on the old version and passes on the new one proves two things: the test catches the problem, and the fix works.
Where failures come from:
Source | Example for the invoice agent |
|---|---|
Alarms on code checks | The totals check fails on a live invoice |
Low LLM judge scores in production | Faithfulness drops for one supplier's invoices |
Failure clustering across sessions | Most escalations come from one invoice layout |
Human review of sampled sessions | A reviewer spots a wrong VAT rate the checks missed |
User feedback and corrections | Finance staff correct or reverse a posted invoice |
Downstream errors | The finance system rejects a posting |
User corrections are especially valuable. They are failures your evaluators missed, so they also tell you which evaluator to add.
Triage: not every failure is an agent bug.

Evaluator bugs matter as much as agent bugs. A judge that raises false alarms trains the team to ignore it.
Writing the failure as a test case:
- Copy the input from the production session, masking sensitive data according to your data policy.
- Write the ground truth (expected outcome, a few assertions, the expected tool path if it matters) and tag it with input type, failure pattern, root cause, severity and the original session ID. AgentCore supports expected responses, assertions and expected trajectories as ground truth .
- Check that it fails on the current version; fix; check that it passes; add it to the next version of the golden dataset.
Example: a credit note with a negative total was posted as a normal invoice. The new test case uses the masked credit note as input. Its expected outcome is "escalated as a credit note, not posted", and it adds the assertion "never posts a negative total as a payable".
Keeping the golden dataset relevant over time. A golden dataset decays. Your agent gains features, your users bring new kinds of input, and the world it works in changes: suppliers redesign invoices, policies and limits change, reference data moves on. A dataset that isn't maintained slowly stops representing reality, and its scores become reassuring but meaningless.

- One test case per failure pattern, not per occurrence, and keep the dataset balanced across input types, so one noisy pattern doesn't dominate. Report results per input type as well as overall.
- Hold some test cases out. Keep 10–20% that nobody tunes prompts against. If the main set improves but the held-out set doesn't, you're fitting the prompts to the tests.
- Keep up with change. Add test cases for new input types and features as soon as they reach production, not only when they fail. Prefer rules and ranges over exact values, e.g. "required fields present" or "total within 1%". When a long-standing test case starts failing, ask first whether the world changed (refresh the ground truth) or the agent broke (fix it).
- Retire obsolete test cases and record why, and version the dataset, recording which version each release was tested against.
Treat the golden dataset like code. The habits above are the ones teams already apply to software, so manage the dataset the same way. Keep the test cases in version control next to the agent. Add or change them through a reviewed change, such as a pull request, where a second person checks that the input is masked and the ground truth is right. Run each change automatically against the current agent before merging: a test case that captures an open bug should fail, and an updated one should pass on the version it describes. Then tag a dataset version with each release. In effect, it's CI/CD for your golden dataset. Every change is reviewed, tested and traceable, so when a score moves, you can always tell whether the agent or the dataset changed.
Measure the loop itself: close to 100% of agent-bug failures should get a test case, within days rather than months. Repeat failures (the same pattern twice) should be zero, and escaped failures (found by users, missed by evaluators) should fall over time.
AgentCore support for the loop:
- Find failures in online evaluation results and Amazon CloudWatch alarms.
- Group them into patterns by running batch evaluation over a production time window with the
Builtin.FailureAnalysisinsight evaluator . It returns each pattern with a root cause and a suggested fix.
- Store and run test cases with managed evaluation datasets and dataset runners (in public preview at the time of writing).
- Validate improvements with AgentCore's optimization capabilities, which generate recommendations from production traces and test them with batch evaluations and A/B tests ( announcement ).
7. How to set the sampling rate for online evaluation
AgentCore online evaluation lets you choose what percentage of live sessions gets evaluated: the sampling rate, anywhere from 0.01% to 100%. But how do you pick that number? By gut feeling? By trial and error? Get it wrong in either direction and you pay for it:

There is a principled way to choose, the same one used for opinion polls and scientific surveys. You decide two things: how sure you want to be (the confidence level) and how close to the truth the score must be (the margin of error). Statistics then tells you how many sessions to evaluate in each reporting period. Divide that number by the total number of sessions in the period, and you have your sampling rate.
The terms used in this section. We introduce each term once and use exactly the same name throughout:
Term | Plain-language meaning |
|---|---|
Pass rate | Share of sessions that pass an evaluator, e.g. 85%. Works the same for an average score between 0 and 1 |
True pass rate | The pass rate if you evaluated every session. Never known exactly |
Measured pass rate | The pass rate of the sessions you did evaluate: your estimate of the true pass rate |
Margin of error | How far the measured pass rate may be from the true one, in ± percentage points |
Likely range | Measured pass rate ± margin of error, e.g. 85% ± 5 points = 80%–90% |
Confidence level | How often the likely range contains the true pass rate, e.g. 95% |
Reporting period | The window you read and act on scores over, e.g. one week |
Evaluated sessions | The sessions in a reporting period that online evaluation scores |
Sampling rate | Evaluated sessions ÷ total sessions in the reporting period |
7.1 Margin of error and confidence level, in plain English
When you evaluate only a sample of sessions, the measured pass rate is an estimate of the true pass rate. The agent and the LLM judge also vary from run to run, so the same session can score differently twice. Two numbers tell you how far to trust the estimate.
- Margin of error is written in percentage points, an absolute difference on the 0–100% scale ("points" for short). A measured pass rate of 85% ± 5 points gives a likely range of 80% to 90%. That's not ±5% of 85%, which would be 80.75%–89.25%. On AgentCore's 0–1 score scale, ±5 points is ±0.05.
- Confidence level, in plain English: a 95% confidence level means that if you repeated the whole measurement 100 times with fresh sessions, about 95 of the likely ranges would contain the true pass rate, and about 5 would miss it.
The two numbers are linked. For the same evaluated sessions, a higher confidence level gives a larger margin of error. You can be more sure only of a wider range. Here are the three confidence levels people typically use, for one example: a measured pass rate of 85% on 200 evaluated sessions.
Confidence level | Plain meaning | Margin of error | Likely range | Typical use |
|---|---|---|---|---|
90% | The likely range misses the true pass rate about 1 time in 10 | ± 4.2 points | 80.8% – 89.2% | Quick, low-stakes checks |
95% | Misses about 1 time in 20 | ± 4.9 points | 80.1% – 89.9% | The usual default |
99% | Misses about 1 time in 100 | ± 6.5 points | 78.5% – 91.5% | High-stakes decisions, e.g. a compliance gate |
The other lever is the number of evaluated sessions: more evaluated sessions give a smaller margin of error. The chart shows how fast it shrinks, at a 95% confidence level and a pass rate around 85%:

With only 20 evaluated sessions, the margin of error is about ±16 points. A measured pass rate of 85% then has a likely range of about 69% to 100%, almost useless for a decision. That's why scores from small samples seem to jump around for no reason.
7.2 How many sessions to evaluate: how p, e and z fit together
The number of sessions to evaluate per reporting period comes from a standard formula for estimating a percentage ( explanation ):
n ≈ z² × p × (1 − p) ÷ e²
- n: evaluated sessions needed per reporting period · z: set by the confidence level · p: the expected pass rate · e: the margin of error, as a fraction
You choose two of the inputs and look up their values; your data gives the third; your traffic turns the result into a sampling rate. You never calculate z, you look it up:

Worked example, step by step:
- Confidence level 95%, so z = 1.96, and z² = 3.84.
- Margin of error ±5 points, so e = 0.05, and e² = 0.0025.
- Expected pass rate unknown, so p = 0.5, and p × (1 − p) = 0.25.
- n ≈ 3.84 × 0.25 ÷ 0.0025 = 384.2. Always round up: 385 evaluated sessions per reporting period.
- With 1,000 total sessions a week, the sampling rate is 385 ÷ 1,000 ≈ 39%.
Two notes:
- If you already know the expected pass rate is around 85%, p × (1 − p) drops from 0.25 to about 0.13, and you need roughly half as many evaluated sessions: about 200.
- It works for scores, not only pass/fail. Many AgentCore evaluators return values between 0 and 1, for example 0.5 for "partially correct". Using p = 0.5 is the worst case for any score between 0 and 1, so the result stays safe.
7.3 The sampling lookup table
You don't have to do the calculation yourself. To use the table:
- Choose your confidence level (the row).
- Find your total sessions per reporting period (the column).
- Read off the sampling rate to set.
The table assumes a margin of error of ±5 points and the safe expected pass rate p = 0.5. The columns are your total sessions per week, and each cell is the sampling rate to set.
Confidence level | Evaluated sessions needed (n) | 500 per week | 1K per week | 2K per week | 5K per week | 1K per week | 5K per week | 100K per week |
|---|---|---|---|---|---|---|---|---|
90% (quick checks) | 271 | 54% | 27% | 14% | 5.4% | 2.7% | 0.6% | 0.3% |
95% (the default) | 385 | 77% | 39% | 19% | 7.7% | 3.9% | 0.8% | 0.4% |
99% (high stakes) | 664 | 100%* | 66% | 33% | 13% | 6.6% | 1.3% | 0.7% |
*Evaluate every session. With only 500 sessions, even 100% can't get the margin of error down to ±5 points at a 99% confidence level.
The number of evaluated sessions you need stays the same whatever your traffic, so the busier your agent, the lower the sampling rate you need.
Adjustments:
- Monthly reporting period? Use your total sessions per month instead.
- A margin of error of ±10 points is enough? Divide the sampling rate by 4. Doubling the margin of error needs a quarter of the evaluated sessions.
- Expected pass rate known to be around 85% (or 15%)? Roughly halve the sampling rate.
- Code checks are cheap: set them to 100%, whatever the table says. The table is for the LLM judges.
7.4 Setting it up in AgentCore: two online configurations
In AgentCore, the sampling rate is set per online evaluation configuration , not per evaluator. A configuration also defines which agent's traces to read, which evaluators to run, optional filters and a session timeout. To run code checks on every session and LLM judges on a sample, create two configurations on the same agent:

Use filters to skip sessions that can't be evaluated meaningfully, such as empty input. Set the session timeout above your longest real session, so long sessions aren't evaluated before they finish.
7.5 Reading scores at release time
The same ideas apply to release decisions in the outer loop, where you run each test case several times:
- Never compare single runs. Report each score as measured pass rate ± margin of error.
- Report "passed in all runs" per test case. A case that fails 2 out of 20 times has a real, intermittent defect, even if its average looks fine.
- Treat a change as real only when it's bigger than the margin of error. On a 0–1 scale, a drop from 0.88 to 0.85 with a margin of error of ±0.06 is noise; a drop from 0.88 to 0.75 is a regression. The same applies when comparing your current model with a candidate model.
- Separate agent noise from judge noise. Re-score the same stored sessions two or three times. If the scores move, the judge itself is noisy. Consider a code check or a stricter rubric.
8. What drives evaluation cost
LLM judges are billed by the tokens they read and write; code checks and custom evaluators per evaluation. See AgentCore pricing for current rates. A judge re-reads the conversation so far each time it runs, including large tool outputs. So its level multiplies the cost:

A rough formula:
monthly judge cost ≈ sessions × sampling rate × Σ over judges (runs per session × tokens per run × price per token)
Every factor is a lever. From most to least effective:
- Drop evaluators that don't lead to a fix (section 4.4 in Part 1 ).
- Enforce instead of evaluating where you can (section 5.2 in Part 1 ).
- Replace judges with code for anything exact (section 5.1 in Part 1 ).
- Prefer session-level LLM judges in production; keep trace- and tool-call-level judges for the golden dataset.
- Size the sampling rate statistically (section 7.3).
- Run full golden dataset runs as batch jobs, where that's cheaper.
- Keep very large tool outputs out of the trace where you don't need them, because LLM judges re-read them.
Make cost visible next to quality. Each AgentCore evaluation result includes
tokenUsage ( EvaluationResultContent ). Multiply it by current prices (also in the AWS Price List API, service code AmazonBedrockAgentCore ) and show each evaluator's cost next to its score, so the regular review can ask: is it worth it?
9. Keep improving
9.1 The one-page evaluation plan
Before building anything, write one line per quality dimension. One page is enough. It becomes your contract for what "good" means, and good evidence for any governance or approval process. Each line answers twelve questions:
Quality dimension (which part of success?) · Behaviour (what would we observe?) · Method (enforce, code check, LLM judge or human review?) · Evidence (where in the trace, and is it recorded?) · Level · Loop · Ground truth · Threshold · Action on breach (block, alarm or backlog?) · Fix if low (what exactly will we change?) · Owner · Cost per month
An example plan for the invoice agent (illustrative values):
Dimension | Method / level | Threshold | Action on breach | Fix if low |
|---|---|---|---|---|
D1 Fields match schema | Code check, session; all loops | 100% | Block release; alarm | Fix the extraction prompt or parser |
D2 Approval policy | Code check + negative test cases; all loops | 100% | Policy incident | Fix the rule, or enforce it in the agent |
D3 Totals reconcile | Code check, session; all loops | 100% | Block release | Improve line-item extraction |
D4 Escalation | Code check + LLM judge; outer and production loops | ≥ 95% | Backlog | Adjust the escalation rules or prompt |
D5 Honest reporting | LLM judges: faithfulness; goal success with assertions | No drop beyond the margin of error | Block release | Read the explanations; fix the claims |
D6 Posted data correct | Data check vs expected postings; nightly | ≥ 99% of fields | Block release; triage | Fix the extraction or the mapping |
D7 Efficiency | Code check; outer and production loops | e.g. median ≤ 6 steps | Backlog | Simplify prompts or tools |
9.2 Run it as a routine, not a project
Evaluation keeps working only if someone owns each number, looks at it on a schedule and acts.
When | What | Typical owner |
|---|---|---|
Every change | Smoke set; block the change if a code check with a 100% threshold fails | Developer |
Every release | Full golden dataset; compare with the last release using the margin of error (section 7.5) | Evaluation owner |
Weekly | Review low scores and failure patterns; read a few real sessions by hand; add new test cases (section 6.3) | Evaluation owner and a developer |
Monthly | Each evaluator's cost vs the decisions it drove; remove evaluators or lower their sampling rate; recalculate the sampling rate if traffic changed; refresh stale ground truth | Team lead |
On alarm | A code check with a 100% threshold fails in production | On-call owner |
9.3 Adapt the framework to your agent
The steps stay the same for every agent. What changes is the balance between LLM judges and code checks:

Agent type | Most checks come from | Watch out for |
|---|---|---|
Conversational (support, Q&A) | LLM judges with expected answers; safety judges for public users | LLM judge variance: calibrate often |
Retrieval-augmented | Faithfulness, context relevance; code checks on citations | Wrong retrieval vs wrong use of what was retrieved |
Task / workflow | Code checks on actions, fields and policy | Many rules can be enforced instead |
Artifact-producing (code, reports) | Code checks; run it and compare with expected output | Judging the description instead of the artifact |
Multi-agent | Session-level evaluators plus targeted trace-level ones | Trace-level LLM judges multiply cost |
For starter evaluator sets per agent type (customer support, multi-step research, domain content) with evaluator IDs, see The agent evaluation playbook .
9.4 Common traps, and the fix for each
Trap | Instead |
|---|---|
Switching on every evaluator, never removing any | Only evaluators with a fix; regular pruning |
Judging the text when the deliverable is an action or artifact | Check the deliverable directly |
One LLM judge with a long list of assertions, some it can't verify from the trace | Move exact assertions to code checks; record the evidence |
Comparing single runs | Many runs; measured pass rate ± margin of error |
Expensive trace-level LLM judges in production | Session-level judges, code checks, a sized sampling rate |
Fixing a failure without adding a test case | Every agent bug becomes a test case; keep a held-out set |
10. Putting it all together

Getting started:
- Write one sentence of success for your agent, and break it into 5–8 quality dimensions.
- Fill in the one-page plan. Any evaluator without a "fix if low" doesn't go in.
- Move deterministic rules into the agent, and write code-based evaluators for the exact checks.
- Add two or three LLM judges for the judgement parts, and calibrate them against your own labels.
- Build a small golden dataset (or start with parity, section 6.2), and run it on every change (smoke set) and every release (full golden dataset, many runs).
- Turn on online evaluation: code checks at a 100% sampling rate, LLM judges at the rate from the lookup table.
- Put cost next to quality, review weekly and monthly, and turn every failure into a test.
Conclusion
Agent evaluation fails quietly when it's treated as a collection of metrics. It works when every check exists for a reason, measures what the agent actually delivers, uses the cheapest reliable method, runs at the right moment, and is read with the right amount of statistical humility. Above all, a low score must lead somewhere: a fix, a blocked release, a go or no-go on a new model, or a new test.
Amazon Bedrock AgentCore Evaluations provides the building blocks for every part of it: built-in, third-party, custom and code-based evaluators; on-demand, batch and online modes; ground truth, datasets and failure analysis; and results in Amazon CloudWatch with token usage on every result. The framework is what turns those building blocks into decisions.
Next steps: start with the AgentCore Evaluations documentation , pick your two or three evaluators with The agent evaluation playbook , and write your one-page plan.
Further reading
- Automated agent evaluation with Amazon Bedrock AgentCore and GitHub Actions : CI/CD quality gates
- Evaluating AI agents: a production blueprint with Strands and AgentCore : from local tests to production monitoring and shadow mode
- The agent evaluation playbook : starter evaluator sets per agent type
- Documentation: Evaluation types · Ground truth · Online evaluation setup · Batch insights · Datasets · Pricing
Series: Evaluations that lead to decisions (2 articles)
- 2Evaluations that lead to decisions, Part 2: golden datasets, sampling, cost and continuous improvement for AI agents on Amazon Bedrock AgentCore This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article