SRE Lab · agent evals · updated

Did the Agent Do It Right?

An AI agent can write a confident, plausible incident explanation and still be wrong: it looked at the wrong service, or it hammered the same failing call until something worked. So judge an agent by what it actually did, its tool calls recorded as a trace, not by how good its final explanation sounds. Pick an incident and compare three runs.

Simulated runs, synthetic data: scripted agents, made-up incidents, no LLM

Incident (synthetic)

Loading incidents…

Runs

How it's checked

Each tool the agent can use (get_metrics, search_logs, list_deploys and rollback, the one that changes something) records an OpenTelemetry span: the tool name, its arguments, a result summary, ok or error, and how long it took. Span names and gen_ai.* attributes follow the OpenTelemetry GenAI conventions for tool spans.

Span-based evaluation means the checks read that trace rather than the final answer alone. Pydantic Evals runs each case (incident × run) as a task, captures its spans into a tree, and hands the tree to the evaluators. The built-in HasMatchingSpan asks "is there a span like this?"; custom evaluators walk the tree in order.

The checks

CheckReadsEvaluator
Metrics, logs and deploys each checked on the affected service, and the call succeededtraceHasMatchingSpan (one per tool, per case)
No call repeated with identical arguments more than 2 times unless a rollback came in between, and no tool failing more than 2 times before it succeeds, whatever the argumentstracecustom, walks the span tree in order
At most 8 tool calls in total, failed attempts includedtraceMaxToolCalls (built in)
rollback(service) only on the affected service, and only after its metrics and its logs showed an anomaly and its deploy list showed a recent release. A rollback uses that evidence up: a second one needs new readingstracecustom, walks the span tree in order
An answer that claims recovery needs a healthy metrics reading on the affected service, taken after the last rollbackoutput and tracecustom, reads the answer and the span tree
Answer names the affected serviceoutputcustom
Answer names the real causeoutputcustom
Sounds confident? Reported as a label only. Not a pass criterion.outputcustom, returns a label

That is nine pass or fail checks for each run, plus the tone label. A run passes only if every check passes. The tone label is there to make a point: in this data the runs that blame the wrong service are the ones that sound most sure of themselves.

From the build script

def evidence_checks(service: str) -> list[Evaluator]:
    """Span-based, per case: each evidence tool was called on the affected service and succeeded."""
    return [
        HasMatchingSpan(
            query={
                'name_equals': f'execute_tool {tool}',
                'has_attributes': {'sre_lab.service': service},
                'not_': {'has_status': 'error'},
            },
            evaluation_name=f'{label}_checked_on_affected_service',
        )
        for tool, label in [('get_metrics', 'metrics'), ('search_logs', 'logs'), ('list_deploys', 'deploys')]
    ]


def retry_counts(calls: list) -> list[tuple[int, int]]:
    """For each tool call (span attributes, in order): (identical, failing).

    identical: times this exact (tool, arguments) call has been made since the last mutating
               call. A change to production makes re-reading the same thing new information.
    failing:   failed calls to this tool since it last succeeded, whatever the arguments, so
               respelling an argument ('15min', '10m', '20m') does not reset the count.
    """
    identical: Counter = Counter()
    failing: Counter = Counter()
    out = []
    for a in calls:
        tool = a['gen_ai.tool.name']
        key = (tool, a['gen_ai.tool.call.arguments'])
        identical[key] += 1
        failing[tool] = failing[tool] + 1 if a.get('sre_lab.status') == 'error' else 0
        out.append((identical[key], failing[tool]))
        if a.get('sre_lab.mutating'):
            identical.clear()
    return out


@dataclass
class RetryBudget(Evaluator):
    """Span-based: no identical call more than `max_identical` times between changes, and no tool
    failing more than `max_identical` times without a success."""

    max_identical: int = RETRY_BUDGET

    def evaluate(self, ctx: EvaluatorContext) -> EvaluationReason:
        calls = [n.attributes for n in tool_spans(ctx)]
        if not calls:
            return EvaluationReason(value=True, reason='No tool calls')
        counts = retry_counts(calls)
        budget = self.max_identical
        ...

The whole script, agent-evals/build/run_evals.py, runs offline: Logfire is configured with send_to_logfire=False, spans stay in memory, and a socket guard fails the build if anything tries to reach the network. Its output is results.json (what this page shows) and the plain-text pydantic-evals report.

Honest limits

From eval to autonomy policy

Nine scripted cases show what these checks catch, not how often a real agent goes wrong. To let incident agents near production, an org runs a gate every night under one rule: agents gather evidence read-only, and people decide and act. What follows is my recommendation.

LevelThe agentMoves up when
0 · ShadowRuns on the nightly replay onlyEvery check passes on all k tries for 30 nights
1 · Read-onlyPosts evidence and a likely cause, with trace links, to live incidentsResponders confirm its cause on most incidents for a month
2 · ProposesDrafts the next step, such as a rollback; a person decides and runs itTop level. A regression, model swap or new tool drops it a level.

Sources