Highlights

Contents

Part III
03

Harness evaluation

Fluent answers can describe wrong external state. Agent evaluation must inspect actions and outcomes. Define tasks, denominators, and failure ownership before deciding what to train or repair.

THE AGENT AND ITS TRAINING PATHDefine tools01Run the loop02Measure tasks03Choose training04Build LoRA05Count adapters06Serialize traces07Train and validate08Generate tasks09Check traces10Compare models11Prepare inference12

#Section 15Evaluating agents

The assistant reserves 4 bolts and politely says it reserved 3. The answer reads well and the call is valid JSON, but the stockroom is wrong. Grading fluency would reward the failure.

Why text quality is insufficient

Agent evaluation measures whether a system chooses and executes the right actions and completes the task. Clear text matters, but it does not replace inspecting the environment; a claim of completion is one more thing to verify.

Tool correctness, task completion, and reliability

Tool correctness covers the allowed operation, correct arguments, and valid representation. Task completion means the resulting state meets the request and the final answer describes it accurately. Reliability is how often both hold across tasks, runs, and changes in wording or state.

A CALL CAN PASS EVERY LOCAL CHECK AND FAIL THE TASKSyntaxJSON parsesyesSchemaquantity is an integeryesSelectionreserve is the right toolyesArgumentsrequested 3, generated 4noTask outcomeenvironment matches requestnograde the world the action left behind
Figure 5.16The illustrative wrong-quantity call passes local format checks but fails argument accuracy and the environment-level goal.

Define success before looking at outputs. A benchmark may require one exact outcome while allowing several valid paths, and penalizing every deviation from one reference trace marks correct solutions wrong.

#Section 16Evaluation sets

An inventory agent tested only on successful reservations can learn to call reserve for everything. It looks capable until someone asks for a definition or for stock that does not exist.

Fixed tasks and expected outcomes

An evaluation set is a versioned collection of tasks, starting environments, permitted tools, and grading rules. Expected outcomes describe final conditions, such as one reservation of 3 and 9 remaining. Keep tasks and fixtures fixed across a before-versus-after comparison.

Single-tool tasks, multi-tool tasks, and negative cases

A single-tool task finishes with one operation, such as reading stock. A multi-tool task depends on several observations or actions. Negative cases call for a refusal, a clarification, or no tool, and they test correct restraint rather than padding the dataset with errors.

AN EVALUATION MUST INCLUDE WHEN TO AVOID ACTIONread onlyquery current stockread then writereserve when availableunavailable stockreport refusalno tool neededexplain a reservation
Figure 5.17Four illustrative task families test reading, conditional action, business refusal, and answering without a tool.

Report results by task family so strong reads do not hide a weak write path.

Reset the inventory between trials so one reservation does not change the next task’s start. Record model and template versions, sampling settings, fixtures, tool behavior, and evaluator version with every transcript.

#Section 17Establishing a baseline

You attach LoRA and see fewer malformed calls. Encouraging, but you need to know what the unmodified checkpoint did in the same runtime; changing parser and weights together hides the source of the gain.

Base-model performance

A baseline is the fully specified comparison system. Base-model performance here means the unmodified starting checkpoint, which may already be instruction-tuned, not necessarily a raw pretrained model. Freeze runtime, schemas, tokenizer, template, and tasks before comparing adapters.

Tool-selection accuracy, valid-call rate, and task success

Report tool-selection accuracy, valid-call rate, and task success separately. One checkpoint may pick the right tool in broken syntax; another may emit valid calls to the wrong operation. The same aggregate can hide opposite training needs.

Save baseline transcripts before training. They map the failures and later show whether a gain came from selection, arguments, syntax, or recovery. Section 61 returns to this comparison.

#Section 18Tool selection accuracy

With current stock already in view, the assistant calls get_stock again. The call is harmless and valid, but it is wasted work that can exhaust a tight budget before the reservation.

Correct tool, wrong tool, missing tool use, and unnecessary tool use

Tool selection accuracy measures whether the chosen operation matches what the task needs at that point. The classes are correct tool, wrong tool, missing tool use when evidence or action is needed, and unnecessary tool use. Include an explicit no_tool choice in the grading.

Count decision points, including missed calls. Counting only generated calls lets a model escape evaluation by never using a tool.

At the first step, get_stock is right. After the read returns 12, reserve is right if the user authorized it. After the receipt shows 9, a final answer is right. The same tool is right at one stage and wrong at another.

When several tools satisfy a task, label the acceptable set. When calls can run in parallel, grade dependencies, not one linear order, or the evaluator punishes freedom instead of errors.

TOOL CHOICE DEPENDS ON WHAT THE NEXT DECISION NEEDSWhat does this request need?an explanationanswer directlyno toolcurrent evidenceget_stockread onlyauthorized actionreservestate changeavailability is a gate; it is not the reason to calla tool can be available and still unnecessary for this task
Figure 5.18An illustrative decision tree for the stockroom’s operation types, with the no-tool branch visible. Being in the registry does not make a call necessary.

#Section 19Argument accuracy

The model picks reserve with sku="nut". The tool is right; the item is wrong. Arguments need their own grade.

Correct values, correct types, missing arguments, and hallucinated arguments

Argument accuracy checks meaning as well as type. Values must come from the request, current observations, or documented defaults. Missing arguments leave required information out. Hallucinated arguments are invented fields or values the task does not support.

Report argument accuracy over valid calls and over all attempts, naming each denominator.

Quantity must be 3, and the schema only says it is a positive integer. The server cannot tell that 4 contradicts the request unless authorization encodes the approved operation, so bind authorization to the relevant arguments.

Compare parsed values, not JSON field order. Missing and explicit null can differ. Normalize dates, amounts, and units only by a documented rule, since silent conversion hides exactly the errors training should fix.

#Section 20Tool-call validity

The correct quantity sits inside a truncated object. The intent is right, but the runtime cannot execute it. Syntax failures and wrong business decisions need different training examples.

JSON validity, schema compliance, valid tool names, and complete arguments

A valid call passes the protocol’s syntax check, names an allowed operation, and supplies complete schema-compliant arguments, plus any envelope rules such as a unique call ID. Keep this definition fixed across baseline and adapted model.

Keep invalid attempts even after recovery. Scoring only dispatched calls makes validity perfect by construction.

EACH METRIC COUNTS A DIFFERENT POPULATIONselection18 / 20 = 90.00%call validity22 / 24 = 91.67%arguments | valid19 / 22 = 86.36%task success16 / 20 = 80.00%recovery | errors3 / 5 = 60.00%illustrative fixtures; argument accuracy is conditional here
Figure 5.19These illustrative metrics use explicit populations. The same numerator gives a different rate when validity, semantics, or task outcomes define the denominator.

Constrained decoding improves syntax but cannot choose the right quantity, and a parser bug can reject correct output. Keep raw and normalized output so failure analysis can tell them apart.

Report calls per task beside validity. Many unnecessary valid calls inflate the call-level sample while hurting completion and latency.

#Section 21Task-level success

The agent reads and reserves correctly, then says 12 remain. The environment is right and the answer is wrong. A complete task needs the intended effect and an accurate report.

Tool correctness vs final-task correctness

Task-level success checks the user’s goal after the whole trajectory: environment assertions, evidence-grounded text, correct refusals, and the action budget. Correct individual calls are often necessary but never sufficient.

Here 16 successes in 20 tasks give 80%. Each task counts once however many calls it made, so long successful trajectories cannot outweigh short failures.

Partial completion and multi-step success

Partial completion records fulfilled subgoals without calling the whole request done. A correct read is progress on a reservation task, not completion, and a wrong final number can be a separate bucket from a wrong committed quantity.

INDEPENDENT 90% STEPS COMPOUND: THREE OF THEM SUCCEED 72.9% OF THE TIME1.000.91 step0.812 steps0.7293 steps0.9, 0.9², 0.9³ under an illustrative independence model; real errors correlate
Figure 5.20Computed success probability after one, two, and three independent 90% steps. The independence model is illustrative, not a claim about real agent errors.

Prefer final-state assertions. Exact trace matching fits only when the contract requires that trace; a retry through an idempotency key can legitimately differ from the shortest demonstration.

#Section 22Agent metrics

A model completes more tasks with many extra calls and twice the time. Whether it is better depends on the requirements, and one score cannot cover quality, cost, and reliability at once.

Success rate, valid-call rate, and average tool calls

An agent metric measures a specified behavior or resource. Success uses attempted tasks; call validity uses attempted calls. Include zero-call tasks when measuring average calls.

Error-recovery rate

Error-recovery rate measures resolved eligible error episodes. Reporting a business refusal correctly is not a failed retry.

Latency and token usage

Latency measures elapsed time between named boundaries. Report tail behavior as well as the average.

Token usage separates input, generated output, and retained tool results. Account for cached input explicitly; token counts do not directly determine time.

#Section 23Failure analysis

The request fails. Retraining now is premature if the tool server ran the wrong operation or the evaluator checked stale state. Find the earliest wrong transition in the record.

Model failure, prompt failure, and schema failure

A failure analysis assigns evidence-backed causes instead of “the model was confused.” A model failure picks the wrong item despite correct context. A prompt failure describes quantity as a percentage. A schema failure allows ambiguous units or demands a field the model cannot know.

Parser failure, tool failure, and evaluation failure

A parser failure misreads a valid representation. A tool failure mishandles a correct request or returns broken evidence. An evaluation failure uses a wrong expected outcome, rejects an equivalent trace, or forgets to reset fixtures. Each needs a different fix.

FIND THE FIRST WRONG TRANSITIONpromptwrong permissions describedmodelwrong quantity proposedschema / parservalid call rejectedtoolcorrect call executed incorrectlyevaluationcorrect outcome graded wrongthe final sentence does not tell you which component failed
Figure 5.21The first incorrect transition identifies an owner to investigate. Several owners can contribute, so a primary bucket should not erase secondary evidence.

For the wrong-quantity trace, compare the raw quantity=4 with the requested 3. If normalization kept 4 and the tool reserved 4 correctly, the error came before dispatch. If the model emitted 3 and normalization changed it, the model must not be blamed or trained on a contradictory example.

Give each failed task one primary cause so totals reconcile, plus tags for contributing conditions. Save transcripts with environment snapshots so a fix can be tested against the exact failing transition.