Agent Harness I7: Event Streams, Span Trees, and pass^k for Reproducible Evaluations
One lucky pass hides a 50% failure rate; treating a single run as a metric is how flaky agents ship. I7 gives harnesses the same CI discipline as unit tests: confidence intervals, regression gates, and a replayable trace, so a tool that fails intermittently becomes a gate that fails the build instead of a surprise in production.
I7 builds on the event stream already defined in I1–I6 and turns single runs into reproducible readings. Events are the only source of truth: every metric must trace back to an event. Spans are generated from runtime nesting, named after OpenTelemetry GenAI conventions, and metrics count only what the events support - turns, tool attempts, retries, tool errors, compactions, stop reason, usage. The transcript is JSONL, one event per line, preserving timestamps so it can be replayed by any evaluator.
Fixtures are deterministic: a task, scripted model responses, an executor factory that takes a trial number to inject per-run failures, and assertions. The suite runs each case k times and reports pass^k, the fraction of cases where all k runs pass, with a Wilson 95% confidence interval. A regression gate compares the current result to a baseline that stores the suite hash, repeats, and per-case pass rates; any drop or a changed hash rejects the run, distinguishing code regression from evaluation drift.
Verification shows a flaky tool passing 2 out of 4 runs, which a single run would miss. The migration path adds events at run boundaries, consumes them with build_spans and collect_metrics, writes 3-5 fixtures, and stores a baseline for CI. Boundaries are explicit: fixtures are not online distributions, pass^k is an estimate, judges must be independent of the generator to avoid reward hacking, and request bodies stay out of the event stream to keep traces deterministic and diffable.
The example of a flaky tool returning 42 on 503 shows why a single run is a misleading sample: the harness records completed even when the tool fails intermittently, so only repeated runs with pass^k expose the real 50% failure rate.
By requiring every metric to be derivable from the event stream, the design blocks vanity metrics that look good on a dashboard but have no path to production; it forces instrumentation to be the actual source of truth.
The warning about LLM-as-judge is not new, but tying it to the closed-loop of using the same model to score and then update prompts makes it concrete: the loop collapses toward the model's own bias, and the regression gate can't see it because the metric itself is contaminated.