Task scenarios and success criteria

Study time
≈ 2 h (estimate)
Needs
L3-M02-L05
Updated
2026-11-04

Progress is saved in this browser only. No account, nothing is sent to a server.

Draft · reviewed by AI, not yet by a person. Content may change. English translation: AI-assisted, not human-reviewed.
On this page

Module: L3-M03 · Duration: ~120 minutes (estimate, including the independent exercise) · Previous: L3-M02-L05 (MCP for testers) · Next: L02

1. Introduction

The two earlier modules test pieces of the agent: the loop and the trace (L3-M01), the tool layer (L3-M02). Users do not care which piece is right; they care whether the task is done. A multi-step task (look up a book, borrow it, keep a note) can pass every per-tool test and still end wrong, and the agent can still write "Done" on the last line.

This lesson opens module L3-M03 with the unit of testing for a task: a scenario that describes the goal, the starting state, the success conditions and the scope of allowed change, together with an end-state oracle that reads the environment instead of the agent's words. The product: eleven ThuVien Mini (fictional) scenarios, an oracle that runs on two simulated agents, and three broken specs fixed until the lint comes back clean. The agents in the lab are simulated programs written by the author; no model, network or API is called.

2. Learning objectives

  1. Name the four parts of a scenario (goal, setup, checks, scope) and the three sources a check can read (state, log, message). Read: §4.1, §4.2.
  2. Run the end-state oracle on a simulated run and read pass, failed and collateral. Practice: §8.2 (part B), §8.3 (lines 2 to 4).
  3. Tell apart a gain check (false at the start) from a guard (true at the start). Read: §5.1.
  4. Detect changes outside the scope with diff_state and collateral. Practice: §8.3 (lines 5 and 6).
  5. Run the scenario-spec lint and state what the lint and the oracle do not check. Practice: §8.2 (part C), §8.3 (line 7). Read: §6.1.
  6. Fix three broken specs until the lint is clean and the oracle catches the defective agents. Practice: §9.

3. Required knowledge and tools

  • L3-M02-L04 (the mock tool layer, the effect log), L3-M01-L02 (the agent loop), L3-M01-L01 (the sandbox), L1-M01-L01 (the oracle). Code lab code-labs/l3-m03, only pytest is needed. The lab copies the files it needs from the L3-M02 lab and does not import from the old lab.
  • Separating the meanings. A scenario here is a multi-step task together with how to grade it; it differs from a "sample" in the L2-M02 dataset (one input and output pair) and from a "test case" in L3-M02 (one call). The end state (or outcome) is a snapshot of the environment after the run; the message is the final text the agent sends the user; the log is the list of tool calls. The oracle is still the mechanism that decides pass or fail (L1-M01-L01). A check is a testable statement about the state, the log or the message.
  • The old policy still stands: offline, mock tools in a sandbox, no model call. The oracle only flags; a person decides what a failure means and every real effect.

4. Concept explanations

4.1 What a scenario contains

A scenario in the lab is a data object (data/scenarios.json) with four parts: the goal (the sentence a user would send), the setup (loans already there, notes already there, the budget, the approved keys), the success checks (the success list, each check with an id, a kind and a weight) and the scope (scope: the books, notes and number of notices the agent may change).

Three sources read on 2026-11-04 describe the same shape. Anthropic's article on evaluating agents uses the words task (a test with inputs and success criteria), trial (one attempt), grader (the scoring logic) and check (an assertion inside a grader) [R4]. τ-bench gives each task an instruction for the simulated user and an annotation of the correct database write actions, then computes the reward from the final database [R1]. AppWorld ties each task to a set of expected changes and a set of changes that are allowed but not required [R2]. The lab's scope (scope) corresponds to the second set and the success checks correspond to the first; the implementation is the lab's own and does not copy the way of any source.

4.2 End state is not the message

Anthropic's article gives an example: a flight-booking agent may write "Your flight has been booked" at the end of the transcript, but the outcome is whether a reservation exists in the environment's SQL database [R4]. The same article advises grading what the agent produced rather than the path it took, so as not to punish creativity [R4]. WebArena gives a similar reason for web tasks: many environments compare the surface form of the action sequence with a reference sequence and ignore whether the result works or whether another solution would do, so WebArena measures functional correctness [R3].

Diagram of a scenario and the end-state oracle: the scenario, made of a goal, a setup, checks and a scope, goes into the run of the simulated agent; the run produces three things, the end state, the call log and the final message; all three go into the oracle, which returns pass, failed and collateral; a person reads the result and decides.
Diagram: End state is not the message

5. Technical deep dive

5.1 The end-state oracle in the lab

lab/scenario.py has four small functions. evaluate(check, snap, history, final_text) returns true or false for one check: six kinds read the state (loan, no_loan, note, no_note, notice, no_notice), one kind reads the log (called: tool X was called at least n times) and one kind reads the message (final_has: the message contains a phrase, case-insensitive). diff_state(before, after) lists changes such as loan+:B001, note~:audit, notice+:S0042. collateral(scope, before, after) returns the changes outside the scope. oracle(...) returns {pass, failed, collateral}: PASS needs every check true at the end and no change outside the scope.

One distinction is used throughout the module. A gain check is false in the starting state: the agent must do something for it to become true. A guard check is already true at the start and may only stay true. gain_ids(sc) computes the starting state from the setup and returns the gain ids. The reason: a check that is true from the start proves nothing about what the agent did. The "no copy is free" scenario (s04) has the guard "B002 is still S0007's" plus two evidence-type gain checks (get_book was called at least twice, the message says nothing was changed).

lint_scenario(sc, known_books) returns findings {code, where}: MISSING_FIELD, BAD_ID, HIDDEN_CHARS, BAD_SETUP, BAD_SCOPE, NO_CHECKS, UNKNOWN_KIND, MISSING_CHECK_FIELD, DUP_CHECK_ID, BAD_WEIGHT, UNKNOWN_REQUIRES, UNKNOWN_BOOK, NO_STATE_CHECK (no check reads the state), NOTHING_TO_GAIN (every check is already true at the start: any agent passes), MESSAGE_ONLY (every gain check reads only the message) and EVIDENCE_NEEDS_STATE (a log or message check is not tied to a state check through requires). The lint never raises for a wrongly typed spec; the wrong type is a finding.

6. QA perspective

6.1 What the oracle and the lint do not say

  • The oracle does not know whether the goal matches what the user meant; it checks only what the scenario author wrote. A vaguely written goal with a strict oracle is still a poor scenario.
  • A change that is wrong but inside the scope is not caught by collateral: the right book to the wrong student is still inside the book scope. Catching it is the job of the loan check, so the check must name both the book and the student.
  • called counts attempts, not results; final_has is a substring match. Both are weak evidence and only mean something next to a state check or when there is nothing to gain (§5.1).
  • The assumption that the correct result is unique. τ-bench designs the instruction so that only one outcome is possible under the domain policy [R1]; AppWorld handles many valid end states with the expected-changes set and the allowed-changes set [R2]. The lab follows the first way, so a correct but different solution (for example a note with another name) is flagged as a fail.
  • The simulated agents were written by the lab author together with the scenarios: a defect the author did not think of is carried by no agent. The suite measures no real agent or model.

7. Real-world scenarios

Scenario 1 (fictional): "Done". The lab's claim_only agent calls no tool and answers "Done: lent B001 to S0042; note loan_s0042 saved." A message-based oracle (the message starts with "Done") says pass; the end-state oracle says fail because there is no loan and no note. The person reading the report sees the two checks c1, c2 fail and checks the log: there is no call.

Scenario 2 (fictional): "Extra work". The overreach agent finishes the task and also writes an extra note audit that nobody asked for. Every success check is true, but collateral lists note+:audit, so the oracle fails. The scope is what separates "did it right" from "did it right and did more".

8. Hands-on tutorial

8.1 Setup

cd academy-content/code-labs/l3-m03
python3 -m venv .venv && source .venv/bin/activate     # Windows: .venv\Scripts\activate
python -m pip install -r requirements.txt
python -m pytest            # 72 passed

8.2 Run the demo

python -m lab.demo l01

Output (copied from a real run on Python 3.14.6 and 3.12 (3.12.14 macOS, 3.12.3 Linux), 2026-11-04; the two versions give identical output). Every agent is simulated:

A. scenario lint of the 11 shipped scenarios
   findings=0
B. s01: the end-state oracle on three SIMULATED agents
   diligent: message_oracle=True end_state_pass=True failed=[] collateral=[]
   claim_only: message_oracle=True end_state_pass=False failed=['c1', 'c2'] collateral=[]
   overreach: message_oracle=True end_state_pass=False failed=[] collateral=['note+:audit']
C. lint of three broken specs
   message only: ['MESSAGE_ONLY', 'NO_STATE_CHECK']
   no-op scenario without a call check: ['MESSAGE_ONLY']
   message check not tied to the loan: ['EVIDENCE_NEEDS_STATE']

Reading the output: part A gives eleven scenarios and no finding. Part B: all three agents pass the message-based oracle, but only diligent passes the end-state oracle; claim_only fails two checks, overreach meets the checks but has a change outside the scope. Part C: a check set with only a message check gets two findings, the "no copy is free" scenario without a called check gets MESSAGE_ONLY, and a message check not tied to the loan gets EVIDENCE_NEEDS_STATE.

8.3 Try it yourself

Save as try_l01.py in the lab's root folder (next to lab/, not inside lab/), run python try_l01.py, then delete the file:

import copy

from lab import scenario as S, workflow as W

sc = {s["id"]: s for s in S.load_scenarios()}
s01 = sc["s01"]
print(S.gain_ids(s01), [c["id"] for c in s01["success"]])
for name in ("diligent", "claim_only", "wrong_student"):
    print(name, W.execute(s01, name)["oracle"])
start = S.seed_snapshot(s01["setup"])
after = W.execute(s01, "overreach")["after"]
print(S.diff_state(start, after))
print(S.collateral(s01["scope"], start, after))
bad = copy.deepcopy(s01)
bad["success"].append({"id": "c3", "kind": "final_has", "text": "Done", "weight": 1})
print([f["code"] for f in S.lint_scenario(bad)])

Output (Python 3.14.6 and 3.12, macOS and Linux, identical):

['c1', 'c2'] ['c1', 'c2']
diligent {'pass': True, 'failed': [], 'collateral': []}
claim_only {'pass': False, 'failed': ['c1', 'c2'], 'collateral': []}
wrong_student {'pass': False, 'failed': ['c1'], 'collateral': []}
['loan+:B001', 'note+:audit', 'note+:loan_s0042']
['note+:audit']
['EVIDENCE_NEEDS_STATE']

Reading: line 1: scenario s01 has two gain checks. Lines 2 to 4: diligent passes; claim_only fails c1 and c2; wrong_student fails only c1, because the note is still right while the loan goes to another student (S0043). Line 5: diff_state lists three changes, including note+:audit. Line 6: only note+:audit is outside the scope. Line 7: adding a message check without requires makes the lint report EVIDENCE_NEEDS_STATE.

8.4 Run the lesson tests

python -m pytest tests/test_l01_scenario.py -v

Result: 18 passed. Read test_a_message_oracle_is_fooled_and_the_end_state_oracle_is_not, test_the_oracle_catches_damage_inside_the_task and test_lint_flags_message_only_and_evidence_without_state. The tests run on in-memory values and a temporary folder.

8.5 Troubleshooting

Symptom Cause Fix
ModuleNotFoundError: lab when running try_l01.py The file is inside lab/ or you run from another folder Put the file next to lab/ and run from the lab's root folder
The oracle passes an agent you believe is wrong The check is incomplete (no student, no note content) or the scenario has NOTHING_TO_GAIN Run lint_scenario; add the right state check, do not loosen the oracle

9. Independent exercise

Problem: Three fictional scenario specs (lend one book and keep a note) are each broken in a different way. Predict what the lint reports, then fix them.

Requirements: complete exercises/test_l01_scenario.py:

  1. TODO 1: CODES_BEFORE: for each spec in exercises/ex_scenarios.json, the set of finding codes that lint_scenario returns. Write your prediction before running anything.
  2. TODO 2: FIXED: the repaired spec for each one. Each repaired spec must lint clean, keep the same id, goal, params, setup and scope, be passed by the diligent agent through the oracle, and not be passed by claim_only, wrong_student or skip_note.

Test data: exercises/ex_scenarios.json.

Deliverable: the two variables above, in the file exercises/test_l01_scenario.py itself.

Acceptance criteria: python -m pytest exercises/test_l01_scenario.py passes (2 tests), recomputed with lab.scenario. The test does not check whether the goal makes sense to a real user.

Hints: TODO 1: go through §5.1 in order (fields, checks, weights, source of each check). TODO 2: a message check cannot be the only check; you need a state check that names both the book and the student, and a check for the note.

10. Knowledge check

0/8 done · Results are kept in this browser only.

P02 · True or false

A scenario in which every check is already true in the starting state is safe to put in the suite, because no agent can fail it.

P04 · Select all that apply

The spec below (fictional) is passed to lint_scenario with known_books set to the lab's six books. Select every finding code that is returned.

spec = {"id": "p1", "title": "t", "goal": "Return B002 for S0123.", "params": {},
        "setup": {"loans": {"B002": {"student": "S0123", "days": 7}}},
        "success": [{"id": "c1", "kind": "loan", "book": "B002", "student": "S0123", "weight": 2},
                    {"id": "c2", "kind": "final_has", "text": "returned", "weight": 1},
                    {"id": "c3", "kind": "called", "tool": "get_book", "min": 1, "weight": 11, "requires": ["c9"]}],
        "scope": {"loans": ["B002"], "notes": [], "notices": 0}, "branches": []}

P05 · Spot the bug

A colleague wrote an end-state oracle. For the agent overreach (does the right work and also writes an extra note audit) on scenario s01, their function returns True. Find the defect.

from lab import scenario as S


def my_oracle(sc, before, after, history, final_text):
    return all(S.evaluate(c, after, history, final_text) for c in sc["success"])

P06 · Essay

Write 5-8 sentences (fictional situation): the wrong_student agent lends the right book B001 but to student S0043 instead of S0042, and the note is right. collateral is empty. Explain why collateral does not catch this defect, which check does, and why the check must name both the book and the student.

P08 · Recall

Lesson: L3-M02-L04

According to L3-M02-L04, which status does ToolLayer.call return for an external tool (such as send_notice) when the request's key has not been approved by a person?

11. Summary

  • Concepts: scenario = goal + setup + checks + scope; the oracle reads the end state, not the message [R3][R4]; a gain check differs from a guard.
  • Skills: run oracle, read failed and collateral, run lint_scenario, write checks that name both the book and the student.
  • Traps: believing "Done"; writing a check that was already true at the start; forgetting the scope and so missing extra work; treating a clean lint as a good scenario [R2].
  • Now you can: take a multi-step task and ask: what is the starting state, which end state is correct, what may the agent change, and who reads the report.

12. References

ID Title Publisher URL Accessed Relevance
R1 τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains (arXiv 2406.12045) arXiv (Yao et al.) https://arxiv.org/abs/2406.12045 2026-11-04 Read the abstract page and the HTML version of the sections on task description, reward and evaluation by final database state; did not read the experiments
R2 AppWorld: A Controllable World of Apps and People for Benchmarking Interactive Coding Agents (arXiv 2407.18901) arXiv (Trivedi et al.) https://arxiv.org/abs/2407.18901 2026-11-04 Read the abstract page and section 3.2 (state-based evaluation, expected and allowed changes); did not read the rest
R3 WebArena: A Realistic Web Environment for Building Autonomous Agents (arXiv 2307.13854) arXiv (Zhou et al.) https://arxiv.org/abs/2307.13854 2026-11-04 Read the abstract page, the introduction on functional evaluation and section 3.2 (evaluating information-seeking tasks); did not read the experiments
R4 Demystifying evals for AI agents Anthropic https://www.anthropic.com/research/demystifying-evals-for-ai-agents (via redirect from anthropic.com/engineering/demystifying-evals-for-ai-agents) 2026-11-04 Read the page text: the terms task, trial, grader, transcript, outcome; grader types; grade the result rather than the path; partial credit

Glossary (English ↔ Tiếng Việt)

English Tiếng Việt
Scenario Kịch bản: mục tiêu, thiết lập, điều kiện thành công, phạm vi
End state (outcome) Trạng thái cuối của môi trường sau lần chạy
End-state oracle Oracle theo trạng thái cuối: đọc môi trường, không đọc lời nhắn
Gain check / guard Điều kiện đạt thêm (sai lúc đầu) / điều kiện giữ nguyên (đúng lúc đầu)
Collateral change Thay đổi ngoài phạm vi được phép