Docs · Guide

Agent output QA

Updated 2026-11-10 Shirish Kadam, Claude Source: docs/engineering/agent-evaluation.md Edit on GitHub

Duct's agents write briefs, audits and posts, so no test can assert the one right answer. This is how we learn whether a change made an agent worse, before it merges.

At a glance

Three tiers, two built

TierRunsChecksLives in
0Every PR, offline, freeThe request sent: system prompt and tool schemas byte-stable across calls, history append-only; the gate's own arithmetic; model, tier, effort and run limits in the prompt dumptests/test_request_invariants.py, tests/test_eval_gate.py, make dump-prompts
1PRs touching agent code, memory, profile or the lock, and merges to main that do. Shadow (reports, never blocks) until an A/A window on main shows no false FAILEach case on a synthetic account: three trials on a PR, six on main, a verdict against its baselinemake agent-eval, agent-eval.yml
2Nightly and weeklyProvider matrix, harder capability cases, private replaysNot built; see the design record

A case plants a story; a trial must find it

A case is a question, a fictional business and a simulated account that answers any date window from daily series, installed under the real data fetch. Solo's world plants one story: the freelance tax guide slipped in Search Console.

Rule: no customer session becomes a case; this repository is public. A real bug becomes a case once it reproduces on a synthetic account, else it stays a private replay (the registry).

A trial is one real agent session on the case. It passes when every deterministic check holds (a brief, no error event, the named entities read, a total quoted exactly as Duct computed it) and every binary judge marker does.

The judge's 1 to 5 scores are logged, never gated: a blended score once hid a failure a yes/no rubric exposed, and yes/no answers resist a judge favouring its own kind.

Verdicts are relative to a baseline

A baseline is a recorded run of the unchanged agent: pass rate, median cost and calls, on a named model.

VerdictMeansThen
PASSPassed as often as the baselineMerge
INCONCLUSIVEOne trial short; or median cost or model calls moved over 30% either way (an effort downgrade shows first as a cost drop); or the baseline is from another modelThree more trials once, locally; on a PR, one line saying why it is acceptable
FAILTwo or more trials shortThe change broke the case

Rule: never raise the trial count, lower a threshold or drop a case to turn a run green. Loosening the gate is its own PR, with the numbers.

Judge biases we design around

Text (the brief, the audit report) goes to GLM 5.3 Flash on OpenRouter through Duct's own model transport; images (the post's slides) to one Gemini call that reads the pixels. The judge returns scores and rationale; we compute the overall, floors and marker gates, so thresholds stay auditable.

The text judge also learns which sources the project had connected; "cites a source it never had" cannot be judged otherwise.

BiasOur answer
Verbosity: long, fluent, formatted answers winThe judge prompt forbids rewarding length, formatting or fluency; the rubric scores substance
Self-preference: a model favours its own outputGLM judges DeepSeek text. Gemini judges Gemini-made slides (the copy is Claude-made): humans spot-check images; a second-provider image judge is the later option
Position: order sways a pairwise verdictWe score pointwise. If A/B regression comes, randomise order and average both
Noise: same input, different verdictLow temperature, structured output, our own threshold math
Miscalibration: scores drift from human judgmentThresholds and weights stay provisional until judge scores correlate with human ratings on a sample

Gotcha: a persona (the judge "masking as the user", say a sound-off scroller judging a hook) is a cheap proxy: simulated users over-ask, are over-polite and diverge systematically. Catch regressions with it; trust absolute numbers only against real retention, saves and shares.

Add a case

  1. Write or reuse a rubric under tests/eval/rubrics/: dimensions, binary markers, pass threshold, persona. Its renderer must show the judge the whole deliverable.
  2. Build the world. Extend Solo's accounts or add a synthetic business; plant the story a good answer must find.
  3. Define the case in tests/eval/cases/: question, context, world, entities to read, totals to quote, markers, caps; register it in CASES, a new agent also in AGENT_PATHS.
  4. Check the check. The case fails on the commit that produced the bad session and passes on the fix.
  5. Record a baseline; a content or audit case also lifts its exclusion in agent-eval.yml.

Re-record a baseline

Only in its own ratchet PR, after a change you mean to keep.

  1. Run enough trials. Three six-trial runs of one agent spread from 3 to 5 passes, so the current baseline pools 18.
  2. Write it. make agent-eval ARGS="-k 18 --write-baseline" records pass rate, medians, model and date in tests/eval/baselines.json.
  3. Put the numbers in the PR body, and nothing else in the diff.

Remember: yes/no checks gate, scores inform, and a case passes when it passes as often as before.

Reference

Files in backend/:

FileHolds
tests/eval/gate.pyCase, Trial, the verdict rules, caps, figure tracing, the report
tests/eval/cases/The registry (CASES, AGENT_PATHS), Solo's accounts (solo_world.py), the insights cases. The account is installed under the real fetch_entity, so envelopes, totals and the payload cut are production code
tests/eval/rubric.pyRubric, Dimension (weighted 1 to 5, with a min_score floor), Marker (required or forbidden), pass_threshold, persona
tests/eval/verdict.pyJudgeVerdict, the judge's structured output; Scorecard, what we compute from it
tests/eval/judge.pyevaluate(): the text judge (Duct's own resolve_chat_model, structured output, cheap enough for every agent PR) and the Gemini vision judge (one call: rubric, text and images in, typed JSON out, so legibility and composition are graded on the pixels)
tests/eval/prompts.pyThe judge's system prompt and persona framing, in one place
tests/eval/client.pyJudge credentials, TEXT_JUDGE_ROUTING, TEXT_JUDGE_REASONING
tests/eval/assertions.pyassert_scorecard for pytest
tests/eval/rubrics/insights_brief.py (binary markers gate), content_post.py, audit_report.py. A renderer shows the judge the whole deliverable: the audit judge once failed two reports for an empty-looking roadmap because the renderer printed the phase labels without their tasks
tests/eval/baselines.jsonOne entry per case: pass rate, medians, trials, provider, model, date
tests/eval/memory_recall.pyThe judge-free memory retrieval eval (50 questions, five axes), run by tests/test_memory_retrieval.py
scripts/agent_eval.pyThe CLI behind make agent-eval; points DATABASE_URL at a throwaway SQLite, never a real database

Consumers of the harness:

ConsumerRunsJudgeTrigger
The eval gate (agent-eval.yml, make agent-eval)The insights case on Solo's accountsText judgeAgent PRs and merges to main; triggers below
tests/test_content_post_e2e.pyThe real content agent drafts a post, generates a slide image and is judged. A second test drives plan mode (enrichment, research sub-agents, WebSearch) with no rubric: one real plan must landGemini vision judgecontent-eval.yml, manual, a Claude leg and a Gemini leg (DUCT_EVAL_PROVIDER, Claude by default)
tests/test_audit_eval.pyA real audit of a site you own, per candidate modelText judge, or Gemini without an OpenRouter keyBy hand, -m live
tests/test_eval_framework.pyScoring logic, rubric rendering, credential resolutionNoneEvery PR

Tier 1 triggers (.github/workflows/agent-eval.yml):

SettingValue
Pathsbackend/agents/** minus content/ and audit/ (no case covers them yet); service/memory.py; service/profile.py; poetry.lock; tests/eval/**; scripts/agent_eval.py; the workflow itself
Draft PRsRun only with the run-evals label
DepthPR: --no-rerun (on 2026-09-30 an unchanged agent came back INCONCLUSIVE at 3/6 and 4/6, so a re-run doubled the price of a noisy read); main: -k 6
SecretOPENROUTER_API_KEY; without it the job says so and passes
Shadowcontinue-on-error until an A/A window on unchanged main shows no false FAIL; making the check required is the owner's decision, in its own PR

Where a failed trial's evidence is:

EvidenceWhere
Each failing trial's reasonsThe step summary
A trial that wrote no briefThe step summary adds the last thing the agent said in chat and any file it wrote to its scratch filesystem instead
Every trial's brief, chat reply, tool calls, scratch files, pulls and judge cardeval-results.jsonl, the run's artifact
Provenance: the share of figures with three or more significant digits that trace to a pullThe report's Figures traced column; a metric, never a gate
What a good brief costs, and how sure the pass rate is (#532)The report's Pass rate, 95% (a Wilson interval: 3/3 is 44% to 100%), Cost per pass (everything spent, failed trials included, over the passes), median tokens in and out, and Cache read (cached share of input) columns; token counts per trial in eval-results.jsonl. Metrics, never gates
A judge verdict that leaves markers outAsked for again, then counted as a judge outage: the trial is judged on its deterministic checks alone, never failed for it

CLI flags and settings (scripts/agent_eval.py):

Flag or settingDefaultDoes
--provider, --model (DUCT_EVAL_PROVIDER, DUCT_EVAL_MODEL)openrouter, deepseek/deepseek-v4-flashThe agent under test
DUCT_JUDGE_PROVIDER, DUCT_JUDGE_MODELopenrouter, z-ai/glm-5.3-flashThe text judge
TEXT_JUDGE_ROUTINGfp8 or better, hosts that take every parameterOf 33 OpenRouter hosts, seven cannot make the verdict's tool call and five run fp4
TEXT_JUDGE_REASONINGlowAt default depth GLM thought 11 to 20k tokens per brief, ran past five minutes, and sometimes answered in prose with no verdict
-k3Trials per case
--no-rerunoffNo three more trials after INCONCLUSIVE
--write-baselineoffRecord this run in baselines.json
--no-judgeoffDeterministic checks only
--budget (DUCT_EVAL_BUDGET_USD)$3Run budget, checked before each batch; judge calls (about a cent) are not counted
--outeval-results.jsonlOne JSON line per trial
--agent, --caseallWhich cases run
Per-case caps$1, 40 model calls, 15 minutes (the Solo case: $0.60)Stop a runaway trial. A case's trials run at once, each on its own thread, so a run takes about as long as its slowest trial; one that will not stop is abandoned (a stalled OpenRouter stream once held a run for three hours). The judge gets 5 minutes

Model history:

DateAgentJudgeWhy
2026-09-28DeepSeek V4 ProDeepSeek V4 ProFirst gate. A trial cost $0.03 to 0.11, a PR run of 3 to 6 trials about $0.25
2026-09-29Every push to a busy PR ran it; the CI key's credits emptied in two days
2026-09-30DeepSeek V4 Flash, about a sixth of the cost per trialGLM 5.3 Flash: a different family, above V4 Pro on Artificial Analysis's Intelligence Index (42 against 36) at a fifth of the priceCost, and no judge grading its own kind. Re-grading 43 stored briefs, GLM agreed with Pro on 96% of checks; every difference was GLM failing a brief Pro had passed, and on the briefs read by hand GLM was right: Pro passed briefs that never said the tax guide fell

The baseline today:

CaseModelTrialsPassedMedian costMedian callsRecorded
insights/solo-organic-slipdeepseek/deepseek-v4-flash1814 (0.778)$0.005242026-09-30

Directions not yet built:

DirectionWhat it adds
Tier 2A nightly regression set, a weekly provider matrix (the model admission list), harder capability cases, private replays
Trajectory checksGrade the process from emitted events, not only the outcome: right tools called, banned ones avoided, turn and budget limits kept
A/B regressionPairwise-judge old against new on a fixed topic set, order randomised, to catch drift between prompt or model changes
Human calibrationHand-score a sample periodically; adjust thresholds and weights from the judge-to-human correlation
Multi-judgeAverage independent judges on high-stakes dimensions. Naive panels amplify shared biases, so keep them independent
Scorecard trendsKeep scorecards where trends and regressions show, in an open-source tool chosen once there are enough to trend

Landscape, 2025 to 2026:

TierToolsWhere we sit
CI gating, lightweight, code-definedPromptfoo (now part of OpenAI; strong red-teaming), DeepEval, RAGASOur harness
Platforms: tracing, human annotation, regression, dashboardsBraintrust, LangSmith, Arize Phoenix, HeliconeThe recommended pairing: a light framework for CI plus a platform for annotation and trends

Sources: