Per-field confidence
Wrap each field in a confidence carrier so a downstream check can decide what needs review. The schema is identical to the one in data labeling; the routing logic is the part that lives here.Route on low confidence
The trigger is plain Python. Walk the fields, find anything below threshold, and decide what to do with it.Gate the next action with requires_confirmation
For a tighter loop, wrap the downstream action (the database write, the ERP push) in a tool that requires approval. Every call to the tool pauses the run until a human confirms it, so nothing posts to the ERP without sign-off.
db. A different process can reconstruct the same Agent configuration and continue with the stored run_id and session_id. See human approval for async variants and listing pending approvals from the database.
Accuracy against a golden set
Confidence routes individual documents. A representative golden set lets you compare extraction behavior across prompt or model changes.AccuracyEval.run() executes its configured agent but does not accept document files. Run document extraction first, then pass its serialized output to run_with_output. AccuracyEval uses a model judge to compare that output with expected_output; it is a semantic score, not an exact field-by-field metric.
db=db stores each evaluation result. Compare model-judge scores across repeated runs with a fixed judge configuration, and add deterministic field checks for invoice numbers, dates, totals, and line items. See the evals cookbook for database logging and the team variant.
Three patterns, one job
The first two gate a single document. The third records a model-judge signal for comparing configurations.