When an agent fails, which layer should you fix?

When an agent fails, which layer should you fix?

Why does a disappointing agent result so often lead to another sentence in the system prompt? If a model provider timed out, a file tool failed or a policy correctly stopped an action, another instruction would address none of those events. Even when the output looks the same to the person waiting for it, the remedy depends on what actually happened. The first job is not to find someone or something to blame. It is to separate what the run recorded from what we still need to establish about the cause.

Consider a procurement colleague asking an agent to compare offers. The draft is incomplete. Perhaps the model stopped early, a relevant context section was removed to meet the budget, or a document tool failed. A later attempt to create an order may also have met a policy block. That block could be correct and unrelated to the draft. This hypothetical task shows how easily one result can acquire the wrong explanation.

A trustworthy record is not a causal explanation

Accepted ADR-0023 in agentic-organization starts with the audit trail: run start, served context, model calls, tool events and policy decisions. It derives findings from these events instead of adopting an external tracing product as the record. But a tamper-evident chain cannot prove that a workstation reported a tool failure accurately, or that a missing event means nothing went wrong.

The current run_diagnosis.py reader produces findings for model, prompt, tool and policy. An upstream error or empty output points toward the model; a section dropped under the token budget points toward prompt assembly. Findings reference chain positions rather than copying conversation text. The reader names a suspect layer only when one score leads. Ties remain unresolved. “Suspect” suggests where to look, not what broke.

Signals have limits. A section skipped for classified intent is not a budget cut. A dry-run policy denial did not stop the action and is not scored as a block. A broken rule causing fail-closed denial differs from an ordinary denial. Client-reported tool errors remain visible but cannot outrank a scored server failure. Diagnosis does not read message or document text. Its identifier-shape filter is not anonymisation; access checks still matter.

The earlier audit-trail article explored an intact chain’s limits. Only instrumented layers produce signals. Guardrail and data problems do not yet emit their own events; “no signal” cannot clear them. Older events may lack origin stamps. Truncated previews are not redacted tasks with expected outputs and fixtures, so the chain cannot replay a task by itself.

Did it succeed? What caused it? What should change?

These are different questions. In judges.py, deterministic checks inspect the diagnosis for model-answer failures, tool errors and policy blocks. Answers can be yes, no or unclear. “The model answered” does not mean “the comparison was useful.” A text-judge helper works on redacted input and can abstain. Connecting it to stored session text under consent rules and calibrating each criterion remain unfinished. The summary API aggregates deterministic results, keeps abstentions separate and displays intervals rather than promising a universal success rate.

To confirm a cause, ADR-0023 proposes replaying a redacted task in a controlled environment while changing only the suspected layer. A changed outcome could upgrade a finding to an attributed cause. Replay has not shipped; suspect counts are not fault rates. ADR-0022 keeps policy and permission changes outside the learnable advice layer, subject to human decisions and security review.

Why not let a model read every transcript and name the culprit? A fluent explanation still needs evidence and exposes more sensitive text. Why not label every policy denial a defect? A correct block can be the successful outcome. The staged design offers bounded signals before judgments and causal tests. Uninstrumented failures may remain unexplained.

The same finding means different work for different teams

In production, an incomplete shift summary might call for checking whether the source data existed before adjusting the prompt. Procurement should distinguish a failed offer-document read from a blocked attempt to create an order. Finance needs to ask whether a blocked payment action was required by the rule rather than counting every block as a failure. HR should consider who can inspect a person’s run history and what happens when responsibility for a persona changes. IT needs to understand which events were reported by a client and which the server observed. These are questions teams can ask of the design, not predefined departmental scores shipped with the product.

Start with one ordinary failed run. Write down what successful work would have looked like before inspecting the trace. Check the run’s model response, the context-section report, tool errors and the actual enforcement state of any policy decision. Then ask whether any of those events explain the user’s complaint, or merely happened nearby. If a layer has no relevant events, record the instrumentation gap rather than marking it healthy. Keep the human judgment about usefulness separate from a deterministic check about whether an API answered. Only propose a change once you can state which additional evidence would make the hypothesis credible.

An organisation does not need a machine that assigns instant blame; it needs a way to choose the next investigation without confusing evidence with certainty. ADR-0023 in agentic-organization makes that distinction explicit by building diagnosis on existing audit events and reserving attribution for confirmed comparisons. When your own agent returns an incomplete result, is the evidence pointing to a layer you can fix, or only to a place where you should begin looking?

Verification note: This article was checked against agentic-organization ADR-0023 and ADR-0022, plus backend/services/run_diagnosis.py, backend/services/run_reader.py, backend/services/judges.py and backend/api/eval.py. Replay and calibrated evaluation of stored session text are not presented as shipped features.