Review the prerequisites
Suitable for: Developers comfortable with Python dictionaries and local SQL transactions.
- Postcondition
- Facts that the business world must satisfy at the end of the task, such as that the report exists and has been published with approved content.
- Hard constraints
- Conditions that must be met individually, such as authorization, number of effects, and budget, are not averaged with language quality.
- Trajectory
- Key actions and their order during execution, used to check process constraints. They do not necessarily prescribe one fixed path.
- Held-out test set
- Samples excluded from tuning, used to evaluate changes on cases the tuning process has not been tailored to.
How does the mechanism work?
- 1Task contract
Fix inputs, required evidence, prohibited actions, and budgets. Keep labels out of model input.
- 2Run record
Bind prompt/model/data versions; retain tool events, artifacts, and business receipts.
- 3Hard gates
Check authorization, structure, citations, budgets, and effect counts separately. An average score cannot offset a dangerous failure.
- 4Semantic review
Check each free-form claim. Mark this dimension not_scored when review has not been performed.
- 5Comparison
Keep all attempts; report task counts, repetitions, denominators, failures, and unscored dimensions.
This experiment contains 8 authored tasks × 3 trials per version. It reports task/trial denominators and rule-gate results; semantic quality, model effects and production reliability are not measured.
Step-by-step explanation
- Define the task contract
Inputs, allowed actions, artifacts, and prohibited behaviors.
- Collect trusted facts
Observe business effects, permissions, usage, and key events.
- Evaluate each dimension
Handle rule checks and semantic review separately.
- Analyze and run regression checks
Report specific failure conditions, then retest changes and different valid paths.
Implementation · Build it
Compute trial, task and judge-error statistics
Objectives of this level: Run the complete fixture grader with preserved identities, denominators and calibration labels.
Visual guide · Independent evidence, separate gates
Authorization, effect count and budget are hard gates. Good prose cannot cancel violations; an unscored dimension remains explicitly unscored. Select the figure to open it at full size.
Download the core experiment bundle on a computer and extract the agent-core-deep-dive-v1 folder. Install Python 3.9+ with its standard library, open a terminal in that folder and run:
python3 -B evaluation_deep_dive.py > evaluation_deep_dive.results.json
python3 -B -m unittest discover -v
Open the saved JSON and compare its statuses/counts with the worked example in this body. The implementation and debugging snippets run from the same extracted folder; the bundle includes every imported module. Save the body’s Python snippet as a .py file in that folder and run python3 -B your_file.py; its printed output is stated beside it. The source can also be downloaded at https://ai.lwkjob.com/lab/deep-dive/evaluation_deep_dive.py. The engineering route continues the same complete after-sales Agent project; full stages are in that package's README.
Run python3 -B evaluation_deep_dive.py. The record schema stores task_id, attempt, provenance, business_ok, authorized, effect count/bound, budget usage/bound, narration score and trajectory. The fixture uses abstract budget units, not measured tokens, dollars or latency.
grade computes hard violations and pass. summary rejects duplicate (task_id, attempt) records before grouping, so copying a passing log cannot inflate the denominator. A has trial success 16/24, tasks with any success 7/8 and tasks with every success 3/8. B has 20/24, 8/8 and 4/8. Both block release. Preserve each task's counts to reveal the failed slices.
The calibration fixture contains four positive and four negative reference labels. Authored judge verdicts yield TP=3, TN=2, FP=2, FN=1: agreement=5/8, acceptance precision=3/5, recall=3/4. Two verdicts change in an authored swapped-order comparison. These are actual calculations over invented verdicts, not measured LLM or human agreement.
Pair versions on identical task/attempt identities before computing task deltas. Keep expected labels and acceptance conditions in the harness; expose only task instructions and authorized inputs to a real agent. Version prompt, tools, data, model, judge and grading policy independently. The lab has no live model version and should not fabricate one.
A complete worked run
Visual guide · Three denominators, same records
A and B are authored eight-task fixtures with three attempts each. Both release gates block; 24 related trials are not 24 independent task contexts. Select the figure to open it at full size.
from evaluation_deep_dive import fixtures, summary, demo
a = summary(fixtures('A'))
b = summary(fixtures('B'))
assert a['trial_success'] == {'numerator': 16, 'denominator': 24}
assert a['tasks_with_all_success'] == {'numerator': 3, 'denominator': 8}
assert b['trial_success'] == {'numerator': 20, 'denominator': 24}
assert b['release_gate'] == 'block'
assert demo()['calibration']['fp'] == 2
print(a['trial_success']['numerator'], b['trial_success']['numerator'], b['release_gate'])
Actual output: 16 20 block. The statistics are reproducible local arithmetic over authored records.
Eight visible calibration pairs
Define reference-positive=True as acceptable support under the chosen rubric; judge-positive=True means the judge accepts it. These are authored labels/verdicts, not human/model observations.
- Reference True, judge True: true positive.
- Reference True, judge True: true positive.
- Reference True, judge False: false negative, a supported case rejected.
- Reference True, judge True: true positive.
- Reference False, judge True: false positive, an unsupported case accepted.
- Reference False, judge False: true negative.
- Reference False, judge False: true negative.
- Reference False, judge True: false positive.
Thus TP=3, TN=2, FP=2, FN=1. Agreement=(TP+TN)/8=5/8. Acceptance precision=TP/(TP+FP)=3/5: of accepted cases, how many were correct? Recall=TP/(TP+FN)=3/4: of reference-positive cases, how many were accepted? Pairs 5 and 8 are especially material if acceptance drives a consequential action.
For version A, the eight task pass vectors are happy=111, alternative_path=111, timeout=101, permission=000, duplicate=101, citation=110, cancel=100, unanswerable=111. Each digit is one trial's contract verdict. They sum to 16/24; seven tasks have any success and three have all success. B changes permission to111 and cancel to101, giving20/24,8/8,4/8. These are task counts, not 24 independently sampled task contexts.
Independently implement grade_copy(row) in your own file before inspecting the reference grade body: pass requires business_ok and all authorization/effect/budget checks. Test the three fixed record types from the foundation, a duplicate effect and an over-budget case. Save your source and compare its verdicts to the reference, keeping the narration score out of the hard checks.
Real-model extension: decision versus atomic-claim contract
Continue with project section 10 and the guide. Twelve public fixtures are not twelve paid task samples: two cases × two versions × two repeats produce eight calls. Reconstruct decision8/8, citation identity8/8 and strict contract1/8 from raw evidence; v1=0/4 and v2=1/4 both block release. Compare every claim with each cited assertion. Seven extra eligibility claims fail this direct-fact contract; they are not seven wrong decisions. The complete function contract lives once in CASE_CONTRACT.md.
Predict before running, preserve your own fault-hook red/diff/unchanged-checker green. Hold context/schema fixed for prompt comparison; do not alter labels after results. Report every POST, two task clusters and repeat denominators. Full-prose semantics remain pending human review.
Grade atoms and derivations separately
Continue section11. Check seven atoms against record assertions; eligibility requires a registered rule and its six validated premises. Keep decision_label_match separate from proof-bound decision_pass. A failed proof is not automatically a wrong business label. Preserve v1 scores0/4 and1/4; two observations under new schema/scope/rules/instructions are not A/B improvement evidence.
See project section11, walkthrough and single contract definition.
Freeze the semantic review object and rubric
Continue section12. Bind full candidate, evidence/rules, as-of/actor scope and rubric version by hash. Two reviewers independently record quotes or omissions, evidence pointers and rationale. Structured proof success is separate from prose quality; reference outcomes are not actual human reviews. The tool validates binding/declaration coverage and never grants release authority.
See section12, review form and workflow.
Separate three outcomes in a full review cycle
Follow section 13 through initial review, adjudication, revision and re-review of the same order. Separate mechanical proof, authored semantic judgments and actual human status. A new record may satisfy schema/binding while teaching_example origin still blocks readiness. simulation_verified is fixed-exercise consistency, not automatic prose scoring or completed human work.
See section 13 and the walkthrough.
Submit independently before reading interpretations
Section 14 separates three source packets from teacher interpretations. Submit S1–S7, quotations or omissions, evidence pointers, material findings and a next step before comparison. Original answers remain available: this is open-book practice, not a blinded test or measured learner completion rate.
See section 14 and the learner instructions.
Run experiments and observe counterexamples
Actual local calculations over authored trial/reference/judge fixtures. No live model, human calibration, measured latency/cost or independent deployment sample.
Python 3.10+ · Runs by default using only the standard library · Runs on your computer
- Compute A/B trial and task ratios.
- Inspect hard-gate slices and narration-only false accepts.
- Inspect the authored judge confusion matrix and assumption-based interval illustrations.
python3 -B evaluation_deep_dive.pyView the entry-point script
"""Actual statistics over authored trial and grader fixtures, Python 3.9+.
No model or human rater was run. Trials are correlated within tasks. This
file demonstrates metric definitions, false acceptance and release gates.
"""
import json
import math
TASKS = ['happy', 'alternative_path', 'timeout', 'permission', 'duplicate', 'citation', 'cancel', 'unanswerable']
PATTERNS = {
'A': [[1,1,1], [1,1,1], [1,0,1], [0,0,0], [1,0,1], [1,1,0], [1,0,0], [1,1,1]],
'B': [[1,1,1], [1,1,1], [1,0,1], [1,1,1], [1,0,1], [1,1,0], [1,0,1], [1,1,1]],
}
def fixtures(version):
records = []
for task, pattern in zip(TASKS, PATTERNS[version]):
for attempt, passing in enumerate(pattern, 1):
row = {'task_id': task, 'attempt': attempt, 'origin': 'authored_trial_fixture',
'business_ok': bool(passing), 'authorized': True, 'effect_count': 0,
'max_effect_count': 1, 'budget_units': 10 + attempt, 'max_budget_units': 20,
'narration_score': 0.95, 'trajectory': ['lookup','verify','finish']}
if task == 'alternative_path':
row['trajectory'] = ['cache','verify','finish']
if task == 'permission' and not passing:
row.update(business_ok=True, authorized=False, effect_count=1)
if task == 'duplicate' and not passing:
row.update(business_ok=True, effect_count=2)
if task == 'cancel' and not passing:
row.update(business_ok=True, budget_units=25)
records.append(row)
return records
def grade(row):
violations = []
if not row['authorized']:
violations.append('authorization')
if row['effect_count'] > row['max_effect_count']:
violations.append('duplicate_effect')
if row['budget_units'] > row['max_budget_units']:
violations.append('budget')
return {'pass': bool(row['business_ok']) and not violations, 'hard_violations': violations}
def trial_identities(records):
if not records:
raise ValueError('empty_dataset')
identities = [(r['task_id'], r['attempt']) for r in records]
if len(set(identities)) != len(identities):
raise ValueError('duplicate_trial_identity')
return set(identities)
def summary(records, minimum_trial_success=1.0):
# This lab's default is deliberately strict. A product must choose its own
# quality threshold and sampling plan before observing candidate scores.
trial_identities(records)
if type(minimum_trial_success) not in (int, float) or not math.isfinite(minimum_trial_success) or not 0 <= minimum_trial_success <= 1:
raise ValueError('quality_threshold')
grouped = {}
for row in records:
grouped.setdefault(row['task_id'], []).append(grade(row))
tasks = [{'task_id': task, 'passed': sum(r['pass'] for r in rows), 'attempts': len(rows),
'any_attempt_passed': any(r['pass'] for r in rows), 'every_attempt_passed': all(r['pass'] for r in rows)}
for task, rows in grouped.items()]
violations = {kind: sum(kind in grade(r)['hard_violations'] for r in records)
for kind in ('authorization','duplicate_effect','budget')}
hard_gate = sum(violations.values()) == 0
passed = sum(grade(r)['pass'] for r in records)
quality_gate = passed / len(records) >= minimum_trial_success
return {'trial_success': {'numerator': passed, 'denominator': len(records)},
'tasks_with_any_success': {'numerator': sum(t['any_attempt_passed'] for t in tasks), 'denominator': len(tasks)},
'tasks_with_all_success': {'numerator': sum(t['every_attempt_passed'] for t in tasks), 'denominator': len(tasks)},
'hard_violations': violations, 'hard_constraint_gate': 'allow' if hard_gate else 'block',
'quality_gate': 'allow' if quality_gate else 'block', 'quality_threshold': minimum_trial_success,
'release_gate': 'allow' if hard_gate and quality_gate else 'block', 'task_results': tasks,
'boundary': 'Descriptive fixture ratios; any-attempt success assumes an oracle chooses a correct attempt and is not a deployed retry policy.'}
def calibration(gold, judge):
if not gold or len(gold) != len(judge) or any(type(v) is not bool for v in gold + judge):
raise ValueError('calibration_shape')
tp = sum(g and j for g,j in zip(gold,judge))
tn = sum(not g and not j for g,j in zip(gold,judge))
fp = sum(not g and j for g,j in zip(gold,judge))
fn = sum(g and not j for g,j in zip(gold,judge))
return {'tp': tp, 'tn': tn, 'fp': fp, 'fn': fn, 'agreement': (tp+tn)/len(gold),
'precision': tp/(tp+fp) if tp+fp else None, 'recall': tp/(tp+fn) if tp+fn else None,
'origin': 'authored_reference_labels_and_judge_verdicts'}
def wilson(successes, total, z=1.959963984540054):
if type(successes) is not int or type(total) is not int or not 0 <= successes <= total or total < 1:
raise ValueError('binomial_counts')
p = successes / total
denom = 1 + z*z/total
center = (p + z*z/(2*total))/denom
radius = z*math.sqrt(p*(1-p)/total + z*z/(4*total*total))/denom
return [max(0, center-radius), min(1, center+radius)]
def zero_failure_upper(n, alpha=0.05):
if type(n) is not int or n < 1 or not 0 < alpha < 1:
raise ValueError('zero_failure_parameters')
return 1 - alpha**(1/n)
def paired_task_deltas(a, b):
attempts_a, attempts_b = trial_identities(a), trial_identities(b)
def group(rows):
result = {}
for r in rows:
result.setdefault(r['task_id'], []).append(grade(r)['pass'])
return result
left, right = group(a), group(b)
if left.keys() != right.keys() or attempts_a != attempts_b:
raise ValueError('unpaired_tasks')
return [{'task_id': t, 'A': sum(left[t])/len(left[t]), 'B': sum(right[t])/len(right[t]),
'delta': sum(right[t])/len(right[t])-sum(left[t])/len(left[t])} for t in left]
def demo():
a, b = fixtures('A'), fixtures('B')
gold = [True,True,True,True,False,False,False,False]
judge = [True,True,False,True,True,False,False,True]
swapped = [True,False,False,True,False,False,False,True]
return {'origin': 'authored_trials_and_judgments_actual_local_statistics', 'versions': {'A': summary(a), 'B': summary(b)},
'narration_only_evaluator': {'accepted': len(a), 'false_accepts': sum(not grade(r)['pass'] for r in a)},
'calibration': calibration(gold, judge),
'order_swap_fixture': {'disagreements': sum(x != y for x,y in zip(judge,swapped)), 'pairs': len(judge)},
'paired_task_deltas': paired_task_deltas(a,b),
'independent_sample_illustration': {'successes': 16, 'n': 24, 'wilson_95': [round(v,6) for v in wilson(16,24)],
'applies_to_trial_fixture': False, 'reason': 'Repeated authored trials are not independent sampled tasks.'},
'zero_failure_illustration': {'n': 30, 'one_sided_95_failure_upper': round(zero_failure_upper(30),6),
'assumption': 'Independent representative Bernoulli trials, stationary failure probability; not established by these fixtures.'},
'boundary': 'No measured model accuracy, latency, monetary cost, human agreement or deployment reliability.'}
if __name__ == '__main__':
print(json.dumps(demo(), indent=2, sort_keys=True))
Expected output when running locally
{
"boundary": "No measured model accuracy, latency, monetary cost, human agreement or deployment reliability.",
"calibration": {
"agreement": 0.625,
"fn": 1,
"fp": 2,
"origin": "authored_reference_labels_and_judge_verdicts",
"precision": 0.6,
"recall": 0.75,
"tn": 2,
"tp": 3
},
"independent_sample_illustration": {
"applies_to_trial_fixture": false,
"n": 24,
"reason": "Repeated authored trials are not independent sampled tasks.",
"successes": 16,
"wilson_95": [
0.467063,
0.820278
]
},
"narration_only_evaluator": {
"accepted": 24,
"false_accepts": 8
},
"order_swap_fixture": {
"disagreements": 2,
"pairs": 8
},
"origin": "authored_trials_and_judgments_actual_local_statistics",
"paired_task_deltas": [
{
"A": 1.0,
"B": 1.0,
"delta": 0.0,
"task_id": "happy"
},
{
"A": 1.0,
"B": 1.0,
"delta": 0.0,
"task_id": "alternative_path"
},
{
"A": 0.6666666666666666,
"B": 0.6666666666666666,
"delta": 0.0,
"task_id": "timeout"
},
{
"A": 0.0,
"B": 1.0,
"delta": 1.0,
"task_id": "permission"
},
{
"A": 0.6666666666666666,
"B": 0.6666666666666666,
"delta": 0.0,
"task_id": "duplicate"
},
{
"A": 0.6666666666666666,
"B": 0.6666666666666666,
"delta": 0.0,
"task_id": "citation"
},
{
"A": 0.3333333333333333,
"B": 0.6666666666666666,
"delta": 0.3333333333333333,
"task_id": "cancel"
},
{
"A": 1.0,
"B": 1.0,
"delta": 0.0,
"task_id": "unanswerable"
}
],
"versions": {
"A": {
"boundary": "Descriptive fixture ratios; any-attempt success assumes an oracle chooses a correct attempt and is not a deployed retry policy.",
"hard_constraint_gate": "block",
"hard_violations": {
"authorization": 3,
"budget": 2,
"duplicate_effect": 1
},
"quality_gate": "block",
"quality_threshold": 1.0,
"release_gate": "block",
"task_results": [
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "happy"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "alternative_path"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "timeout"
},
{
"any_attempt_passed": false,
"attempts": 3,
"every_attempt_passed": false,
"passed": 0,
"task_id": "permission"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "duplicate"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "citation"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 1,
"task_id": "cancel"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "unanswerable"
}
],
"tasks_with_all_success": {
"denominator": 8,
"numerator": 3
},
"tasks_with_any_success": {
"denominator": 8,
"numerator": 7
},
"trial_success": {
"denominator": 24,
"numerator": 16
}
},
"B": {
"boundary": "Descriptive fixture ratios; any-attempt success assumes an oracle chooses a correct attempt and is not a deployed retry policy.",
"hard_constraint_gate": "block",
"hard_violations": {
"authorization": 0,
"budget": 1,
"duplicate_effect": 1
},
"quality_gate": "block",
"quality_threshold": 1.0,
"release_gate": "block",
"task_results": [
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "happy"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "alternative_path"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "timeout"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "permission"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "duplicate"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "citation"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": false,
"passed": 2,
"task_id": "cancel"
},
{
"any_attempt_passed": true,
"attempts": 3,
"every_attempt_passed": true,
"passed": 3,
"task_id": "unanswerable"
}
],
"tasks_with_all_success": {
"denominator": 8,
"numerator": 4
},
"tasks_with_any_success": {
"denominator": 8,
"numerator": 8
},
"trial_success": {
"denominator": 24,
"numerator": 20
}
}
},
"zero_failure_illustration": {
"assumption": "Independent representative Bernoulli trials, stationary failure probability; not established by these fixtures.",
"n": 30,
"one_sided_95_failure_upper": 0.095034
}
}- A=16/24 and B=20/24; both release gates block.
- A any/all-success tasks=7/8 and 3/8; B=8/8 and 4/8.
- Calibration TP/TN/FP/FN=3/2/2/1; false narration accepts=8.
code example
Threshold sensitivity is a policy choice
For A/B compare an explicitly hypothetical minimum_trial_success=0.8 with the teaching default1.0. B meets0.8 by20/24 but still has hard violations, so release remains blocked. Changing a threshold alters the decision policy; it does not alter the observed20/24 or prove the agent improved.
Acceptance task for this level
Run the module; reconstruct A/B trial, any-task, all-task and violation counts from the visible pass vectors. Recompute calibration from the eight visible pairs and identify FP/FN IDs. Independently implement grade_copy and compare it with the reference on the stated cases. Continue the same-project real evaluation; preserve your own initial failure, patch and unchanged checks. Continue evidence-v2 practice; preserve the original failure, your own repair and unchanged-checker results. Complete semantic-review practice, separating teaching references, declaration completeness and actual human signoff. Replay the same-task review cycle, preserving initial reviews, stale-binding rejection and fresh records. Complete three source review exercises, preserving submissions, revisions and manual comparisons.
Reading this browser’s record…
Hide the answer and check your understanding
A duplicate passing record is appended to the dataset. What should the harness do?
Expand reference derivation
Reject duplicate trial identity rather than count it as a new observation. A retry can be a new attempt only when it has an intentional distinct trial identity and its own recorded run provenance.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (5 )
- Acceptance is an evidence contract, not a prose impression · answer independently
- Evaluate both outcomes and execution traces · answer independently
- Independent and representative evaluation samples · answer independently
- A judge is a fallible measurement component · answer independently
- The success metric must match the allowed execution policy · answer independently
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.
- Anthropic: agent evaluation task/trial/outcome distinctions
- NIST: binomial proportion intervals
- Local evaluation statistics and actual results
- Core experiments: download and run on a computer
- Complete after-sales Agent project: run on a computer
- Same-project evaluation, fault decisions and requirement changes
- Frozen traces, grading and budget evidence
- Atomic facts and rule derivations
- Versioned evidence contracts and preserved raw records
- Human semantic review practice
- Zero-request rubric, forms and trace-grounded cases
- Same-task review and repair cycle
- Zero-request cycle execution evidence
- Source-based review practice
- Learner exercise execution evidence