liveBook · Manning

Code-based evaluation

As explained in Build an AI Agent (From Scratch)

Code-based evaluation is automated grading of an agent's response through predefined rules or executable programs.

Code-based evaluation automatically grades an agent’s response with predefined rules or executable programs. It provides fast, objective, reproducible checks as agents, prompts, models, and data change. section 10.3

Common evaluator strategies include:

  • Exact string matching for answers with a fixed expected result. section 10.3
  • Strict format validation, including JSON schemas and required fields. section 10.3
  • Regular-expression or parse-tree comparisons for structured outputs. section 10.3
  • Execution-based evaluation that runs generated code or SQL against test cases. section 10.3
  • Constraint checks for prohibited words, length limits, and policy violations. section 10.3

Regression checking

A CI pipeline can rerun deterministic format, correctness, execution, and constraint checks after a prompt or model change, exposing regressions without manual grading. section 10.3

How Build an AI Agent (From Scratch) covers it

How deep it goes
Defines deterministic rules and several implementation strategies, but stops short of judging subjective natural-language qualities.
Examples
Uses exact matches, schema checks, parse comparisons, code or SQL test execution, and policy constraints.
What it assumes
Assumes evaluation criteria can be expressed precisely in code and distinguishes objective checks from subjective judgment.
What you can do after
Evaluate agent responses reproducibly with explicit rules and automated correctness, format, execution, or constraint checks.
How it connects
Connects to LLM judges, human evaluation, end-user feedback, JSON schema, regular expressions, parse trees, and CI pipelines.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an AI Agent (From Scratch). The section links point to the parts of the book it draws on.