Skip to content

Loop 2–4: Live Evals, pass^k, Nightly Polygon & Judge Calibration

In the AGBoss 5-Loop Cost & Determinism Verification Funnel, once Loop 0 (agboss check) and Loop 1 (npm test) have verified your topology and TypeScript harness for $0, Loops 2–4 evaluate live model trajectories, memory compaction survival, and production telemetry. AGBoss combines in-loop @Judge gates (DecidedBy.Code and DecidedBy.Model), declarative @EvalSuite benchmarks (@agboss/core/eval), Fail-Fast $0 → $$$ cascades, pass@k vs pass^k baseline gates (flaky-on-baseline quarantine), nightly --metamorphic and --chaos polygons, Cohen’s $\kappa$ calibration (agboss eval calibrate), and two production feedback loops (agboss golden & Progressive Crystallization).


Complete example: @Judge quality gates, oneOf narrowing, YAML profile & eval test

Section titled “Complete example: @Judge quality gates, oneOf narrowing, YAML profile & eval test”

Principle 1: How do Loops 2–4 fit into the 5-Loop Verification Funnel?

Section titled “Principle 1: How do Loops 2–4 fit into the 5-Loop Verification Funnel?”

A foundational rule of AGBoss is: never verify with a paid language model what can be proven by the compiler or checked by deterministic TypeScript; and when you invoke a model, check $0 trajectory invariants and code judges first before calling a calibrated LLM judge. See the full 5-Loop Cost & Determinism Verification Funnel architecture for all four objects of verification and both production feedback loops:

Loop Command / Runner Latency & Cost What It Proves
Loop 0: Compiler $ agboss check --federation < 1s · $0 (every save) Object 1 (Topology & Mesh Contracts): Path Scope dominance, { about } staleness, LIFO saga compensations, and Agent Mesh federation schemas
Loop 1: Deterministic Harness npm test (testWith(App), 10 unit runners, VirtualClock, VCR) ~3s · $0 (every commit; locked by [vcr.stale-cassette]) Object 2 (Harness Code): @Action, DecidedBy.Code @Router/@Arbiter, @Tool, @ToolInterceptor, @PiiPolicy, retries, ModelFailure chaos, and { instances: 2 } pod leases
Loop 2: PR Smoke Gate $ agboss eval run --runs 5 --baseline ~1 min · $ (on PR when promptHash / schemaHash changes) Object 3 (Model & Trajectory): Fail-Fast cascade ($0 requiredTools/forbiddenTools/toolInvariant $\to$ $0 code @Judge $\to$ LLM @Judge), pass^5 vs cached --baseline (flaky-on-baseline quarantine), and eval-report.html
Loop 3: Nightly Polygon $ agboss eval run --runs 20 --metamorphic --chaos ~15 min · $$ (nightly on main / pre-release) Objects 3 & 4 (Trajectory & Memory): Full 30–50+ task benchmark with pinned vendorRouting, --metamorphic paraphrase invariance, multi-turn @Compaction survival, stale-memory override, --chaos, and provider drift detection
Loop 4: Production & Feedback Loops A/B ExecutionRecord $\to$ $ agboss eval ui / $ agboss eval calibrate / agboss golden 24/7 · Continuous Loop A: Failure taxonomy tagging, Cohen’s $\kappa \ge 0.80$ judge calibration, and 1-click promotion to golden/*.yaml. Loop B: Progressive Crystallization from paid Loop 2 back into $0 Loop 1

Principle 2: What every Tern stores & RFC 8785 configHash

Section titled “Principle 2: What every Tern stores & RFC 8785 configHash”

In AGBoss, one question-to-answer execution round is called a Tern, and a threadId is a client’s sequence of Terns. Every execution — whether answered, guarded, failed, or paused — writes a Tern into ExecutionRecordRepository containing:

  • task, answer, status, stopReason, route, steps (what each agent/router answered), and cost.
  • promptVersion & modelVersion: Short SHA-256 fingerprints of all agent/router prompts and resolved model settings. Editing a *.prompt.md file automatically produces a new promptVersion.
  • configHash (RFC 8785 Canonical JSON): A 64-character SHA-256 fingerprint (first 8 hex characters shown in agboss describe) computed over RFC 8785 canonical JSON (UTF-16 code-unit key order, locale-independent) covering:
    • elements: Each agent and model router’s active @PiiPolicy rules, uncompactedTurns, @Compaction strategy, and attached @Judges.
    • frame: The framework’s own system framing for routers, tool loops, judge retry prompts, and RAG citations.
    • children: Every reachable child @Workflow recursively.
    • If you modify a workflow’s prompt or flow without bumping @Workflow({ version }), AGBoss logs a drift warning at startup: warning: config "job-scout" 1.0.0 changed without a version bump (hash 3f2a…).

Principle 3: Scoring, calibrating & replaying with agboss eval and agboss replay

Section titled “Principle 3: Scoring, calibrating & replaying with agboss eval and agboss replay”
  1. Calibrate your judge first: Before trusting aggregate eval numbers, inspect and hand-label 20–30 recorded Terns to verify that your decision judge agrees with human domain judgment.
  2. Score unscored Terns (agboss eval score): Scores every unscored answered Tern (P(adequate)) and prints a summary table per promptVersion (total Terns, scored count, mean score, and USD cost).
  3. Replay historical tasks against a prompt edit (agboss replay): Re-runs the stored tasks from <old-prompt-version> against your current code and prompts as new threads (replay_of set), scores both sides, and prints the before → after delta on the exact same tasks. Both eval and replay run strictly inside your @Application({ budgets }) and stop cleanly if a budget cap is reached.

Principle 4: Golden sets & A/B profile comparisons (agboss compare & compareProfiles)

Section titled “Principle 4: Golden sets & A/B profile comparisons (agboss compare & compareProfiles)”

A profile YAML file (profiles/<workflow-name>/<profile>.yaml) overrides defaults, compactions.<name>, agents.*, or prompts without touching TypeScript code.

From the CLI (agboss golden & agboss compare)

Section titled “From the CLI (agboss golden & agboss compare)”

agboss compare runs each golden task as a fresh first-contact turn on every listed profile, computes mean adequacy score, runs randomized-order pairwise A/B judging (wins/losses/ties vs base), and reports total cost, cost per task, p50/p95 latency, and a diff of the exact settings that changed:

You can also invoke compareProfiles programmatically inside custom benchmark scripts or Vitest evaluation suites:


Principle 5: Declarative @EvalSuite, pass@k / pass^k, Calibration & Eval UI

Section titled “Principle 5: Declarative @EvalSuite, pass@k / pass^k, Calibration & Eval UI”

In addition to scoring recorded Terns, @agboss/core/eval lets you declare typed, multi-turn evaluation suites (@EvalSuite) with trajectory expectations (checkTrajectory(), toolCall, toolInvariant) and Fail-Fast cascading judges (EvalCascade.StopAtFirstFailure, running $0 DecidedBy.Code judges before DecidedBy.Model judges):

Multi-Run Reliability (pass@k vs pass^k), Regression Gates & Calibration

Section titled “Multi-Run Reliability (pass@k vs pass^k), Regression Gates & Calibration”
Capability How It Works
pass@k vs pass^k (--runs <k>) pass@k measures whether a case passed at least once in $k$ trials (capability); pass^k measures whether it passed all $k$ of $k$ trials (production reliability). High pass@k (1.00) paired with low pass^k (< 0.80) marks the case unstable and flags the step as a Progressive Crystallization candidate.
Baseline Regression Gate (--baseline --fail-on-regression) Compares every case against a baseline report JSON (exit code 5 on new failures). Any case whose baseline had 0 < pass^k < 1 is marked flaky-on-baseline (CaseComparison.FlakyOnBaseline) and quarantined so baseline noise never blocks unrelated pull requests.
Judge Calibration (eval calibrate & Cohen’s $\kappa$) Computes pairwise Cohen’s kappa ($\kappa$), a confusion matrix (TP, FP, TN, FN), disagreements, and per-metric rubrics between each @Judge and human EvalLabel JSONL annotations (eval/labels/<suite>.jsonl). Also warns with [judge.same-model-family] when a model judge shares the evaluated agent’s model family.
Chaos (--chaos <rate> --chaos-seed <n>) & Metamorphic (--metamorphic) --chaos injects transient provider faults (429, timeouts, truncated answers) below ProviderFetch to verify retry and .onError() resilience; --metamorphic runs case variants and verifies that the tool-call trajectory (metamorphic check) remains invariant across prompt rewordings.
Production Flywheel (generate eval-case --from-execution & records export) Reads an ExecutionRecord from ExecutionHistoryRepository (SqliteExecutionHistoryRepository), turns its conversation history, input, and required tool calls into a typed evalCase(...) in your @EvalSuite, and exports JSONL records (agboss records export) for offline auditing and agboss hub.
HTML Report (eval show --html) & Interactive Workbench (eval ui) Generates a self-contained single-file HTML report for CI artifacts (eval run --html or eval show <run.json> --html), or launches a local web workbench (127.0.0.1) to inspect multi-turn trajectories, tag failure modes, label runs with live $\kappa$ recalculation, and promote production traces into @EvalSuite cases.

Inspect 03-support-refund-desk in agbossjs/agboss-examples for a complete runnable @EvalSuite (src/eval-suites/refund-desk.eval-suite.ts), compact git-diff-friendly baseline (eval/baseline/main-baseline.json), human label calibration (eval/human-labels/refund-desk-eval-suite.jsonl), and PII-safe generate eval-case promotion (see 7 Verified Examples).