Module: L3-M06 · Duration: ~110 minutes (estimate, including the independent exercise) · Previous: L04 (cost and latency budgets) · Next: module L3-M07
1. Introduction
The four previous lessons gave you four kinds of evidence: outcomes under injected faults (L01), duplicate effects (L02), success rates across repeated trials (L03), cost and latency (L04). The person who decides whether the ThuVien Mini assistant (fictional) is ready will not read 100 run records. They read a reliability report: what was run, what was measured under which definition, against which targets set beforehand, what was seen, and what was not seen.
A reliability report reuses the regression report (L1-M06-L05) and the reproducible experiment report (L2-M07-L05), and adds three things specific to agents: targets per task with pass^k (not just one overall rate), a fault-injection section with the outcome of each plan, and a limits section that says which faults were not injected.
What the lesson produces: lab/report.py (build_report, validate_report, gate, render), the report of the safe configuration in Markdown (§8.2), and in §9 you fix another team's broken draft report without hiding any finding, then build a report from your own runs.
2. Learning objectives
- List the six sections of a reliability report and what each section must answer. Read: §4.1.
- Explain why targets must be set beforehand, numbers must be recomputable from the runs, and results must be per task. Read: §4.2.
- Use
validate_reportto find where a report is broken, fix it without dropping any unfavourable run or outcome, and build a report from your own runs. Read: §5.1. Practice: §8.2 (part B), §9 (TODO 1, TODO 2, TODO 4). - Read the gate's HOLD reasons, write the limits section, and read and comment on a decision note for the reviewer. Read: §5.2, §6.1. Practice: §8.3, §9 (TODO 3, TODO 4).
3. Prerequisites and tools
- L1-M06-L05 (regression reports, triage), L2-M07-L05 (reproducible reports), L2-M07-L04 (a gate that closes when data is missing), L3-M04-L05 (a gate only says HOLD or READY_FOR_REVIEW), and L01-L04 of this module. Code lab
code-labs/l3-m06. - Keep the meanings apart. A report is a document for a reader; a gate is a function that reads a report and says HOLD or READY_FOR_REVIEW. READY_FOR_REVIEW means "a person should read this report now", not release. No function in the lab approves anything.
- Every run, number and name in the report is simulated and fictional.
4. Concept explanation
4.1 The six sections of a reliability report
The lab's report is a dict with six sections (report.SECTIONS), and render prints it as Markdown in the same order:
| Section | Question it answers | In the lab |
|---|---|---|
meta (Scope) |
Which product, which configuration, which seed, how many trials per task, when | product, config, seed, n, date |
targets (Targets) |
What "good enough" means, decided before running | k, min_pass_hat_k, min_wilson_low |
trials (Repeated results) |
How many successes out of how many for each task, pass@1, pass^k, the Wilson interval | a summary of each run (identity, configuration, seed, trial, success, duplicate, tokens, cu, latency), counts, rows |
faults (Fault injection) |
Under each fault plan, whether the agent recovered, failed honestly, failed silently or duplicated | one row per test (fault_row): the plan's name and rules, task, configuration, unfired rules, outcome (L01) |
budgets (Budgets) |
Which tasks go over tokens, cost, p50, p95 | the result of check_budget, with the method and budgets used (L04) |
limits (Limits) |
What the report does not show | a list of specific sentences, non-empty, no duplicates |
The results section states each measure's definition with its source: pass^k as τ-bench's C(c, k)/C(n, k) [R2], pass@1 = c/n, the Wilson interval following NIST [R4], percentiles by nearest-rank; a number without a definition cannot be compared (L04, §5.1). The limits section records what L01 listed as not injected, what the lab simplifies (a scripted agent, a simulated clock) and how wide the intervals are when n is small.
The principles of chaos engineering say that the harder it is to disrupt the steady state, "the more confidence we have in the behavior of the system" [R1]. A reliability report records that confidence: "we tried to break it in these ways, and this is what happened".
4.2 What the reader must be able to check
Three rules make a report checkable:
- Targets set beforehand. A target written after seeing the results is always met. The gate does not know when a target was set; that is the job of the process and of the reviewer.
- Every number can be recomputed from the runs.
countsmust match the list of runs;rows(the pass@1, pass^k, Wilson table) must matchcounts; the budget table must match the tokens, cu and latency of the runs. As in L2-M07-L05: a number in a report must be traceable to data. - Per task. L03 (§5.2) showed that pooling 100 runs into 82/100 hides two tasks below 0.8. The report has one row per task, and the targets apply to each task.
And reading transcripts is still a person's job: you will not know whether a grader is any good "unless you read the transcripts and grades from many trials" [R3]. A loud_failure or not_fired row is an invitation to open that run's transcript, not a conclusion.
5. Technical deep dive
5.1 validate_report: shape and consistency
validate_report(rep) returns sorted error codes and never raises. The shape group: NOT_A_DICT, MISSING_SECTION:<section>, BAD_META, BAD_TARGET (a target that is a string such as "0.6" or "60%", or is True), K_ABOVE_N, NO_TASKS, BAD_RUN (including a NaN latency), BAD_COUNTS (a count that is not a pair of integers, such as [20, 17.0]), NO_FAULT_TESTS, BAD_FAULT_ROW (a missing field, rules that do not pass validate_plan), EMPTY_PLAN (a row with no rules: it tests nothing), BAD_OUTCOME (outside the seven outcomes of L01, ok under a fault plan, or not_fired with no unfired rule), BAD_BUDGETS, NO_LIMITS (empty, or a sentence under 15 characters), DUPLICATE_LIMIT (two sentences that are the same after normalising whitespace and case).
The consistency group is the more important part:
| Code | Meaning |
|---|---|
UNFINISHED_RUN |
a run whose status is not finished: the report was written before the runs finished |
DUPLICATE_RUN_ID |
a run appears twice (a paste mistake) |
RUN_IDENTITY |
a run_id that is not <task>-<config>-s<seed>-t<trial>, a configuration or seed that differs from meta, or the trials of a task are not exactly 0 to n−1 (a run from another configuration, or relabelled) |
COUNT_MISMATCH |
counts does not match the number of runs and successes recounted from the list, or a task's n differs from meta.n |
ROW_MISMATCH |
the rows table does not match the rows recomputed from counts (for example someone typed a better pass^4 into the table) |
CONFIG_MISMATCH |
a fault-injection row comes from a configuration other than the report's |
PLAN_MISMATCH, FAULT_TASK_UNKNOWN |
the name of a lab plan carries different rules; a fault-injection row targets a task that is not in the results |
BUDGET_PROBLEMS, BUDGET_TASKS_DIFFER |
check_budget reported problems, or the budget table does not have the same tasks as the results |
BUDGET_MISMATCH |
a budget row, or the P95_IS_MAX warning, differs from the row recomputed from the runs' tokens, cu and latency |
The order of the checks has consequences: ROW_MISMATCH is only checked once counts matches and the targets are valid. Fix counts but forget to recompute the table, and a new code appears. The blind spot in the docstring: the function checks that the report agrees with itself, not that the list of runs really is what was run. An author who edits the run summaries and everything derived from them at the same time will not be caught; that is why the raw run records must travel with the report. The outcome of a fault-injection row is also self-declared: the function checks that it is consistent with that row's rules and unfired rules, not that the run behind it is real.
5.2 gate: recompute, then read
gate(rep) runs its whole body inside a block that catches every exception; if there is any code, it returns HOLD with the reason malformed: <code> and stops there. For a valid report, the gate recomputes from counts and does not read rows: for each task, a pass^k below min_pass_hat_k gives the reason pass^k below target, and an unrounded Wilson lower bound below min_wilson_low gives success-rate lower bound below target. Then: each run with a duplicate effect (duplicate side effect in trial), each fault-injection row whose outcome is not_fired, not_observed, silent_failure, duplicate or loud_failure, each row that still has unfired rules (fault did not fire: ..., rules [1]), each over-budget code. With no reason, READY_FOR_REVIEW. Budget warnings (P95_IS_MAX) are printed in the report but do not cause HOLD.
Why is loud_failure under a fault a HOLD reason, when L01 called it "honest"? Because the fault-injection rows are tests for the configuration under evaluation, with transient faults it was designed to recover from; an honest failure is still a failure. not_fired and not_observed are HOLD reasons because a test that does not reach its fault, or reaches it without the caller seeing it, is a hole in the report (L01, §6.1): fix the test, not the agent.
6. QA perspective
6.1 Writing limits and the decision note
Part A of the demo (§8.2) is the report of safe under flaky. The gate says HOLD with six reasons. Read them as a reviewer would:
- t01: pass^4 = 0.491, below 0.5. A close call. The Wilson interval of 17/20 is 0.640 to 0.948: the data fit both an agent that meets the target and one that does not. That interval is for p, not for pass^4; raising both ends to the fourth power (a rough plug-in of p, which L03 warned about) gives pass^4 from about 0.17 to 0.81, both sides of the 0.5 target. The right note is "not enough evidence", not "nearly there, let it through". Under the rerun rule of L1-M06-L02, if you run again, use a new seed and draw the conclusion only from the new run.
- t03 and t05: below both targets. A real finding: they fail because of the model's slips (L03), not because of injected faults. The note points to the records of the failed runs.
notice_error_onceon t01: did not fire. A test-suite bug; change that row's task (t02 or t03), then rerun.
The demo's limits section has three sentences: simulated; five tasks and one seed; faults injected only into tools and model text. A good limits section is specific (which faults were not injected, what n is) and not repetitive (validate_report returns DUPLICATE_LIMIT for two sentences that differ only in whitespace or case). The decision note belongs to a person: the gate only says whether the report is ready to be read.
Part B shows what the gate does when someone edits the report by hand (typing a pass^4 into the table, editing counts, leaving a run running, dropping the fault-injection section, relabelling a run, typing a p95 into the budget table, ...): every case is HOLD with a malformed reason, and none makes the gate raise.
7. Real-world scenarios
Scenario 1 (fictional): "Green report, red product". An internal report says READY_FOR_REVIEW for a room-booking assistant. The reviewer reads the fault-injection section and finds only two rows, both recovered, both targeting read tools. That team's gate does not check the limits section, and the section is empty. The numbers are not wrong, but the report never tried a single write. The reviewer sends the report back asking for partial_write and timeout with effect: "after" for every write tool (L02), and a limits section.
Scenario 2 (fictional): "Drop the bad rows to tidy up". A draft is on HOLD because of fault did not fire and a duplicate side effect under fault. The author wants to drop both rows "because one is a test bug and the other already has a ticket". The tester keeps both: fix the test and rerun for the first row; the second stays until the fix has a green duplicate-side-effect test. A report loses findings only through a new run, never through a deletion.
8. Hands-on tutorial
8.1 Setup
cd academy-content/code-labs/l3-m06
python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install -r requirements.txt
python -m pytest # 145 passed
8.2 Run the demo
python -m lab.demo l05
Output (copied from a real run on Python 3.14.6 and 3.12.3, Linux, 2026-11-05; both versions gave identical output). Every run is simulated:
A. the report of the safe configuration under 'flaky' (20 trials per task), rendered
## Báo cáo độ tin cậy: ThuVien Mini (hư cấu)
### 1. Phạm vi
- Cấu hình: `safe`, seed 0, 20 lần chạy mỗi tác vụ, ngày 2026-11-05 (mô phỏng).
- Mục tiêu đặt trước khi chạy: pass^4 >= 0.5, cận dưới Wilson 95% >= 0.6.
### 2. Kết quả lặp lại
| Tác vụ | c/n | pass@1 | pass^4 | Wilson 95% |
|---|---|---|---|---|
| t01 | 17/20 | 0.850 | 0.491 | 0.640-0.948 |
| t02 | 20/20 | 1.000 | 1.000 | 0.839-1.000 |
| t03 | 12/20 | 0.600 | 0.102 | 0.387-0.781 |
| t04 | 20/20 | 1.000 | 1.000 | 0.839-1.000 |
| t05 | 13/20 | 0.650 | 0.148 | 0.433-0.819 |
### 3. Tiêm lỗi
| Kế hoạch lỗi | Tác vụ | Cấu hình | Luật không kích hoạt | Kết cục |
|---|---|---|---|---|
| borrow_error_once | t01 | safe | - | recovered |
| borrow_timeout_after | t01 | safe | - | recovered |
| borrow_partial | t05 | safe | - | recovered |
| borrow_rate_limit | t01 | safe | - | recovered |
| model_truncated | t04 | safe | - | recovered |
| notice_partial | t02 | safe | - | recovered |
| notice_error_once | t01 | safe | [0] | not_fired |
### 4. Ngân sách
| Tác vụ | runs | tokens max | cost max | p50 ms | p95 ms | vượt |
|---|---|---|---|---|---|---|
| t01 | 20 | 2670 | 42 | 3053 | 4697 | - |
| t02 | 20 | 1890 | 29 | 2442 | 4110 | - |
| t03 | 20 | 2170 | 36 | 2420 | 3878 | - |
| t04 | 20 | 1810 | 24 | 2194 | 4105 | - |
| t05 | 20 | 2250 | 38 | 2604 | 3978 | - |
### 5. Giới hạn
- Mô phỏng: agent theo kịch bản, không phải mô hình ngôn ngữ; độ trễ và token là số của lab.
- Chỉ năm tác vụ và một seed; khoảng Wilson rộng khi n = 20.
- Lỗi chỉ tiêm vào tool và vào văn bản của model; không có lỗi API của model, mất mạng giữa chừng hay agent bị dừng.
### 6. Quyết định của cổng
- HOLD
- pass^4 below target: t01
- pass^4 below target: t03
- success-rate lower bound below target: t03
- pass^4 below target: t05
- success-rate lower bound below target: t05
- fault did not fire: notice_error_once on t01
B. the same report, changed by hand: what the gate says
a better pass^4 typed into the table: HOLD ['malformed: ROW_MISMATCH']
counts edited, runs left as they are: HOLD ['malformed: COUNT_MISMATCH']
one run still running: HOLD ['malformed: UNFINISHED_RUN']
k above n: HOLD ['malformed: K_ABOVE_N']
no fault section: HOLD ['malformed: MISSING_SECTION:faults']
no limits: HOLD ['malformed: NO_LIMITS']
a target as a string: HOLD ['malformed: BAD_TARGET']
a fault row with no rules: HOLD ['malformed: EMPTY_PLAN']
a run relabelled as another task: HOLD ['malformed: COUNT_MISMATCH', 'malformed: RUN_IDENTITY']
a p95 typed into the budget table: HOLD ['malformed: BUDGET_MISMATCH']
not a report: HOLD ['malformed: NOT_A_DICT']
Reading the output: part A is the Markdown report printed by render. The results table matches part B of L03 (with safe, the flaky plan changes no result). The fault-injection section has seven rows: six recovered and one not_fired (rule 0 did not fire). The budget section matches the safe / flaky row of L04 part B. The decision section: §6.1. Part B: eleven broken inputs, eleven HOLDs, each with a malformed reason (the relabelled run gives two reasons: wrong counts and wrong identity).
8.3 Try it yourself
Save this as try_l05.py in the lab's root folder, run python try_l05.py, then delete the file:
from lab import agent as A, budget as B, data, report as R, trials as T
res = T.run_trials(["t01", "t02", "t04"], "naive", 20, seed=2, plan=data.plan("slow_search"))
faults = [R.fault_row(p, A.run_task(t, "naive", data.plan(p))) for p, t in (("borrow_error_once", "t01"), ("notice_partial", "t02"))]
meta = {"product": "ThuVien Mini (hư cấu)", "config": "naive", "seed": 2, "n": 20, "date": "2026-11-05"}
rep = R.build_report(meta, {"k": 2, "min_pass_hat_k": 0.5, "min_wilson_low": 0.6}, res, faults,
B.check_budget(res["runs"], data.budgets()), ["Simulated agent, three tasks only."])
print(R.validate_report(rep), rep["trials"]["counts"])
print(R.gate(rep))
Output (Python 3.14.6 and 3.12.3, Linux, identical):
[] {'t01': [20, 20], 't02': [20, 20], 't04': [20, 20]}
{'decision': 'HOLD', 'reasons': ['task failed under fault: borrow_error_once on t01', 'task failed under fault: notice_partial on t02', 'over budget: t01 OVER_P95', 'over budget: t04 OVER_P95']}
Reading: the report of naive on three tasks, seed 2, under slow_search. All three tasks succeed 20/20 (the slow searches still answer before the timeout), yet the gate says HOLD with four reasons: two fault-injection rows with loud_failure (no retries) and the two tasks that search go over p95. A 100% success rate is not a reliability report.
8.4 Run the lesson's tests
python -m pytest tests/test_l05_report.py -v
Result: 25 passed. Read test_the_gate_recomputes_from_counts_and_catches_hand_edits, test_fault_rows_that_test_nothing_or_disagree_with_themselves_hold, test_the_budget_table_is_recomputed_from_the_run_summaries and test_the_gate_never_raises_and_holds_on_junk.
8.5 Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
malformed: ROW_MISMATCH after fixing counts |
The rows table is still computed from the old numbers |
Recompute with R.task_rows(counts, k) |
malformed: COUNT_MISMATCH |
counts typed by hand, or a run pasted twice |
Recount from the list of runs; remove exact duplicates |
malformed: BAD_TARGET |
A target is a string such as "60%" |
Use a number in [0, 1] |
malformed: BUDGET_MISMATCH |
The budget table was edited by hand, or computed on runs other than the list | Recompute with B.check_budget on exactly the report's runs |
malformed: BAD_FAULT_ROW |
A hand-written fault-injection row, missing rules or unfired_rules |
Build the row with R.fault_row(name, run) |
render raises an error |
Called on an invalid report | Run validate_report first; render is only for valid reports |
9. Independent exercise
Problem: Another team sends the draft report exercises/ex_report_l05.json for the configuration retry_new_key (10 trials per task, seed 11). The draft comes from a real simulated run, and then four errors were added while it was being edited. The notes line records the targets agreed before the run.
Requirements: complete exercises/test_l05_report.py:
- TODO 1:
PROBLEMS: the list of codes thatR.validate_report(DRAFT)returns. - TODO 2: the function
fix(draft)returns a new report thatvalidate_reportaccepts. Keep every run (remove only exact duplicates), every fault-injection row, the budgets, and the targets exactly as innotes; recompute what is derived from the runs; write at least two limits of your own. - TODO 3:
REASONS: the list of reasons thatR.gate(fix(DRAFT))returns, in exactly that order. - TODO 4: the function
my_report(): a report from your own runs:T.run_trialson at least three tasks, n ≥ 10, a configuration and seed different from the demo's (safe, seed 0), the runs' fault plan name recorded inmeta["plan"]; at least threeR.fault_rowrows covering at least two kinds of fault;B.check_budgetwithdata.budgets(); targets set before running; at least two limits of your own. The test reruns your runs and fault tests and compares them with the report.
Test data: exercises/ex_report_l05.json.
Deliverable: the two variables and two functions, in the file exercises/test_l05_report.py itself.
Acceptance criteria: python -m pytest exercises/test_l05_report.py passes (4 tests). The test rejects a fix that drops an unfavourable fault-injection row, drops a failed run, lowers a target, or writes two identical limits (even ones that differ only in whitespace or case) or limits that name nothing specific (n, seed, a kind of fault, p95 or Wilson); and a my_report that copies the demo's report or has numbers that cannot be recomputed.
Hints: read §5.1 on the order of the checks before predicting TODO 1: some codes only appear after another code has been fixed. For TODO 3, remember the order in which the gate considers reasons (§5.2), and that a task can pass pass^k and miss the Wilson lower bound.
10. Knowledge check
0/10 done · Results are kept in this browser only.
P02 · True or false
P03 · Fill in the blank
P04 · Select all that apply
P05 · Put in order
P06 · Match
P07 · Spot the bug
This function "tidies up" a report before it is sent. The report then passes validate_report. Find the bug.
def tidy(rep):
out = copy.deepcopy(rep)
out["faults"] = [f for f in out["faults"] if f["outcome"] in ("ok", "recovered")]
out["limits"] = out["limits"] or ["The agent is simulated."]
return outP08 · Essay
In part A of the demo, t01 has pass^4 = 0.491 against a target of 0.5. Write a three-to-five-sentence decision note for the reviewer.
P10 · Recall
Lesson: L3-M06-L0311. Summary
- Concepts: the six sections of a reliability report; targets set beforehand; recomputable numbers; per task; measure definitions with sources [R2][R4]; reading run transcripts [R3]; a report as a record of confidence [R1].
- Skills: build, check and render a report from your own runs; fix a broken report without hiding findings; read HOLD reasons and write limits.
- Traps: trusting hand-typed tables; dropping unfavourable rows; targets set afterwards; one overall rate hiding a broken task; treating READY_FOR_REVIEW as approval.
- You can now: write a reliability report for an agent in which a reviewer can recheck every number, and understand why the gate holds it back.
12. References
| ID | Title | Publisher | URL | Accessed | Relevance |
|---|---|---|---|---|---|
| R1 | Principles of Chaos Engineering | principlesofchaos.org | https://principlesofchaos.org/ | 2026-11-05 | The harder it is to disrupt the steady state, the more confidence in the system |
| R2 | τ-bench (Yao, Shinn, Razavi, Narasimhan), arXiv 2406.12045, 2024 | arXiv | https://arxiv.org/abs/2406.12045 | 2026-11-05 | Definition and estimator of pass^k |
| R3 | Demystifying evals for AI agents | Anthropic | https://www.anthropic.com/research/demystifying-evals-for-ai-agents | 2026-11-05 | Read the transcripts and grades of many trials to know whether the grader works |
| R4 | NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4.1 | NIST | https://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm | 2026-11-05 | The Wilson interval |
Glossary (English ↔ Tiếng Việt)
| English | Tiếng Việt |
|---|---|
| Reliability report | Báo cáo độ tin cậy: phạm vi, mục tiêu đặt trước, kết quả theo tác vụ, tiêm lỗi, ngân sách, giới hạn |
| Pre-registered target | Mục tiêu đặt trước: thống nhất trước lần chạy, ghi trong báo cáo |
| Consistency check | Kiểm nhất quán: số liệu của báo cáo khớp các lần chạy mà nó tóm tắt |
| Limits section | Mục giới hạn: điều báo cáo không cho thấy, cụ thể và không trùng lặp |
| HOLD / READY_FOR_REVIEW | Giữ lại / sẵn sàng để người duyệt đọc; không phải phê duyệt |