All articles
7 min read
#Agent Evals#Verifiable Systems#LLM Production#MCP

How I Use Key-Management Concepts to Design Agent Evals

Five design questions for agent evals: durable state, deterministic recovery, authorization, audit trails, and recovery playbooks.

On this page

Why this matters

I assess an agent using recorded inputs, decisions, tool results, and recovery behavior, rather than a convincing transcript alone. Key management offers a useful design analogy, but an analogy is not evidence that an agent meets banking requirements or has passed a production evaluation.

I want claims about execution to be inspectable. For the key-management background, NIST SP 800-57 Part 1 Rev. 5 provides general guidance on protecting and managing keying material. The mappings below are my design proposals; they are not requirements extracted from that document or reports of client implementations.

Below are five disciplines I apply, with the agent-system mapping.

1. Durable state, not transient context

Key-management analogy: I ask where authoritative material lives, how access is controlled, and how recovery is tested. I do not assume that every system uses the same HSM, backup, or shard arrangement.

Agent parallel: I record intent and the required inputs before an external effect, then record its outcome. A LangGraph checkpointer saves graph state when configured; a thread identifier alone does not create persistent storage. Checkpoint replay can repeat an external call, so idempotency and reconciliation remain separate requirements.

# Not this:
result = agent.invoke(input)  # state only in RAM

# Prerequisite: graph was compiled with a persistent checkpointer.
# A thread_id alone does not enable persistence.
result = graph.invoke(
    input,
    config={"configurable": {"thread_id": session_id}},
)

Cost: added latency and storage per step. Benefit: recorded trajectories give me material to audit and debug.

2. Deterministic failure modes

Key-management analogy: I distinguish a completed operation, a refused operation, and an uncertain outcome. I would not collapse an incomplete protocol into success; the meaning of a partial signature depends on the protocol.

Agent parallel: I would make every tool contract expose typed, exhaustive failure modes. No except Exception: pass. No "just let the LLM retry" without explicit termination. I would use Pydantic schemas for tool I/O, using typed cases for failures the LLM must handle:

from typing import Literal

from pydantic import BaseModel, Field


class Hit(BaseModel):
    title: str
    url: str


class SearchResult(BaseModel):
    status: Literal["ok", "rate_limited", "empty", "auth_error"]
    hits: list[Hit] = Field(default_factory=list)
    retry_after_s: int | None = None

This schema gives the LLM a named case for each failure, so its instructions can say what to do, for example wait when status is rate_limited. An unstructured exception trace offers no named case to act on.

3. Dual control for high-stakes actions

Key-management analogy: I separate the authority to propose an action from the authority to approve it. The exact authorization policy belongs to the system owner and threat model, not to this analogy.

Agent parallel: I define which operations need an independent authorization decision, whether from a person or a deterministic policy service. A second model’s opinion is not automatically an independent security authority. The action, scope, identity, and validity of an authorization need explicit representation.

The LangGraph interrupt mechanism can pause a workflow for external input. I still need to define who may resume it and which action that response authorizes; pausing alone does not implement those controls.

4. Audit trails as evidence, not logs

Key-management analogy: I ask what records would let another operator examine an action and detect unauthorized changes. Timestamps and signatures have specific roles; neither makes the entire storage system tamper-proof.

Agent parallel: I use three distinct terms. A trace records execution events. An audit trail records security-relevant actions and attribution under an explicit retention and integrity policy. A replay fixture contains the inputs, versions, and recorded tool results needed to exercise a specified path. A trace becomes useful evidence only if it retains the required fields and its provenance can be assessed. I would record input, prompt-template hash, model identifier, tool arguments and results, output, and timestamps, subject to data-handling policy. This is a proposed evidence schema, not a claim about a deployed OpenTelemetry, LangSmith, or Postgres implementation.

Why it matters: regressions in LLM systems can be hard to see in aggregate metrics but visible in specific traces. Without replayable evidence, I am left with guesswork during diagnosis.

5. Recovery playbooks for failure, not just success

Key-management analogy: I plan for material becoming unavailable or compromised before relying on the system. The recovery procedure needs an owner and a test, not just a written intention.

Agent parallel: Before I ship, I write down the failure modes I expect to see in production and the recovery action for each:

  • Model unavailable / rate-limited → fallback model routing
  • Tool returning malformed output → circuit breaker + escalation
  • Prompt injection detected → trajectory abort + audit entry
  • State store unavailable → read-only mode, not silent degradation

If I cannot name three plausible failure modes with written recovery paths, I would not ship the system.

The term I use

I use these five questions to review an agent design: what persists, how failures are represented, who authorizes effects, what records support inspection, and how recovery is tested. The comparison with key management does not certify regulatory compliance or deterministic model output.

When a workflow has material consequences, I change the evaluation question from "does it sound right" to "can I prove why it did what it did." I reserve this level of evidence for systems whose effects, recovery requirements, or operating costs justify durable state, reproducible evals, and explicit controls.

If you're evaluating an agent system against those five disciplines and finding gaps, write to me.

FAQ

Why persist agent state before side-effecting tool calls?

I persist agent state before any tool call that has side effects because otherwise it is harder to establish what the agent knew at step N. Durable state adds latency and storage per step, but it is a prerequisite for reliable stateful replay and supports audit and trajectory debugging after an incident.

How should tool failures be represented for an LLM agent?

I would make every tool contract expose typed, exhaustive failure modes instead of unstructured exceptions or silent catches. With a schema such as a status field for ok, rate_limited, empty, or auth_error, I would give the LLM expected cases that its instructions can cover, such as waiting after rate limiting.

When should an agent require human-in-the-loop approval?

I define authorization policy from the action’s risk and the owner’s requirements. A human review or a deterministic policy service can supply an independent decision; a second generative agent alone does not establish that independence.

What evidence should an agent run record for auditability?

I want every run to record the input, prompt template hash, model identifier, tool invocations with arguments and results, final output, and timestamps. I do not rely on logs alone; I want the trace to support replayable evidence for diagnosis.

What recovery paths should exist before production release?

Before I ship, I write down plausible production failure modes and the recovery action for each. Examples include fallback model routing for unavailability or rate limits, a circuit breaker and escalation for malformed tool output, trajectory abort on prompt injection, and read-only mode when the state store is unavailable.

Share this article

Related articles

  • MCP in production: a checklist

    I check seven things before an MCP server touches real data: hints, token audience, scopes, OAuth discovery, local servers, state handles, logs.

    Oct 24, 20269 min read
    #MCP#Security#Agents#Production
  • Multi-Agent Systems: Durable Coordination Patterns

    A stateful architecture for coordinating AI agents with explicit roles, durable handoffs, tool boundaries, and deterministic recovery.

    Nov 14, 202611 min read
    #Multi-Agent Systems#Agent Orchestration#Durable State#Failure Recovery#LLM Evals
  • AI Workflow Engines for Durable, Auditable Systems

    I use an illustrative LLM workflow to examine durable state, recovery, audit records, and cost controls.

    Aug 17, 202612 min read
    #AI workflows#Durable State#Retries#Audit Trails#Evals#Orchestration