Skip to content

AI remediation: from failure to validated improvement

AI remediation is the process of finding why an agent failed in production, changing what caused it, and confirming the fix held before shipping. This matters because many agent failures are silent: the HTTP call succeeds, but the user got the wrong answer or the agent took the wrong path. This guide covers failures in AI agents and LLM apps (wrong answers, wrong tool calls, bad retrieval), not security or vulnerability remediation performed with AI.

By Arun Prasad · Published · Last updated

On this page

Why AI agent failures need a different fix process

AI agents don't fail like normal software. A tool can return a 200 and the task can still fail. Standard monitoring shows the request went through, not whether the answer was right.

That gap matters because many agent failures are silent. The HTTP call succeeds, no exception is raised, and the user gets a reply. What you don't see is that the reply was wrong, the retrieval missed the relevant document, or the agent took a tool path that didn't match what the user asked for.

The other problem is that these failures repeat. The same class of mistake, say, the agent confidently answering questions your Knowledge Base doesn't cover, shows up across dozens of sessions before anyone notices the pattern. By then, users have already seen it.

A useful remediation workflow needs three things your existing error logs won't give you: a record of what the agent said and did (not just whether the call succeeded), a way to group similar failures together, and a method for confirming that whatever you changed actually fixed the right thing. Agent Observability is where that record begins.

Step 1: Capture what the agent did

You can't remediate what you haven't recorded. The raw material for any remediation workflow is a trace: a structured record of one exchange between the user and the agent, including the model called, the tools invoked, the retrieval steps taken, the response returned, and how long it all took.

If your agent already sends traces, you have what you need. If not, two paths work for most stacks:

  • Python SDK: attach a handler to your framework. You get full trajectories (model calls, tool calls, retrieval, handoffs, errors) with one import.
  • HTTP API: one POST per exchange, from TypeScript, Go, Java, or anything the SDK doesn't cover.

The minimum a trace needs to be useful:

Example · text
// Example: POST /api/traces
{
  "project_id": "proj_abc123",
  "model": "claude-3-5-sonnet",
  "input_messages": [
    { "role": "user", "content": "What's the cancellation policy?" }
  ],
  "output_message": "You can cancel within 30 days for a full refund.",
  "latency_ms": 820
}

The API host is https://api.prism.blockconvey.com, and the request carries your PRISM key in the X-PRISMtrace-Key header. Optional fields, session_id, agent_id, token_count_input, token_count_output, metadata, add more signal when you have them, but the required fields above are enough to start.

What you're capturing isn't just the input and output. You're capturing the outcome against the user's goal, which is what root-cause analysis needs later.

Step 2: Score and cluster failures

PRISM analyzes every trace on arrival, at no credit cost. Each plan has a daily ceiling on that scoring: past it, traces are still stored and the deterministic checks still run, and the LLM scoring pauses until 00:00 UTC. Recurring failures are grouped into Issues, so you can see which patterns matter most before spending time debugging individual sessions.

The scores are customer satisfaction (0–100), response quality (0–100, covering accuracy, helpfulness, and clarity), and a detected intent. A trace is flagged for review when either score drops below 40, the reply looks like a hallucination, the user seems very frustrated, or the conversation contradicts itself.

Those flagged traces are the input to clustering. Recurring failures are grouped into Issues, one per kind of mistake, each with a diagnosis and a list of suspect files. That grouping is what lets you see that "agent says it doesn't know" and "agent gives wrong refund amount" are two different problems affecting different sets of sessions, so you can prioritize and fix them separately.

This step doesn't require any configuration. The scoring and clustering happen automatically as traces arrive.

Step 3: Trace each cluster to a cause

In Step 3, you run a root-cause analysis to identify whether the problem stems from the prompt, retrieval, the agent workflow, or another cause, so you know what to change.

Root-cause analysis examines the traces in a cluster and names the most likely cause: prompt, missing source, retrieval, stale state, tool choice, parameter, guardrail or workflow step.

Knowing that 40 sessions failed with the same kind of mistake is useful. Knowing why is what lets you fix it rather than patch around it.

For each Issue cluster, the causes it looks at are:

  • Prompt: the system prompt is ambiguous, too broad, or contradicts the agent's Knowledge Base
  • Missing source: the Knowledge Base doesn't have a document that covers the user's question
  • Retrieval gap: the right document exists but isn't being retrieved
  • Stale state: the agent is working from outdated context
  • Tool choice or parameter: the agent called the wrong tool or passed it the wrong input
  • Guardrail: a rule is blocking legitimate responses, or a gap is letting bad ones through
  • Workflow step: a handoff, loop, or branch in the agent's logic is producing the wrong result

Each root-cause run over a project costs 5 credits. The result is a backlog where every item has a severity, a suggested fix, an owner, an expected impact, and a status, so the team can see what matters most and who is responsible for it.

Step 4: Make the change

In Step 4, you make the change the root-cause recommendation points to: edit the prompt, add a document to the Knowledge Base, tighten a guardrail rule, or modify a workflow step.

Remediation turns the root cause into a concrete recommendation: a specific prompt edit, a document to add to the Knowledge Base, a guardrail rule to tighten, or a workflow step to change.

The recommendations themselves cost no credits. You're paying for the analysis in step 3; the suggested fixes come with it.

Prompt changes are versioned, diffable, and reversible. If you edit the system prompt and something gets worse, you can compare the before and after and roll back. Each approval is attributed to a named person, so the history is clear.

The backlog tracks all of this: severity, suggested fix, owner, expected impact, status. It's the working list of what needs to change, in what order, and whether it's been done.

Step 5: Replay and confirm the fix held

In Step 5, you replay the failing traces against your change to confirm the fix actually worked before you ship it.

A fix attempt drafts a patch and replays the failing traces against it. When your team has turned remediation on and granted write access, and at least 80% of replays pass, PRISM opens a draft pull request for a person to review and merge.

Shipping a change without checking it against the traces that failed is how regressions happen. The last step in a remediation workflow is confirming the fix worked on the specific inputs that broke before.

A fix attempt costs 5 credits. If fewer than 80% of replays pass, no pull request is opened.

A few things to know about the approval model:

  • Nothing ships without human sign-off. PRISM opens a draft pull request; a person reviews and merges it.
  • For code changes, a draft pull request is opened only when your team has turned remediation on and granted write access, and only if at least 80% of replays pass.
  • Failed jobs don't use credits. The deduction happens only once the result exists.

After a fix is merged, PRISM compares pass rates for the 7 days before the merge and the 7 days after. That comparison is your evidence that the fix held in production, not just on the replay set.

How this looks in production

Here is what the AI Remediation workflow produces at each stage.

Root-cause output: a backlog item

After a root-cause run, each item in the backlog shows the cause, severity, suggested fix, owner, expected impact and status. A retrieval-gap item might read:

  • Cause: retrieval gap
  • Severity: high
  • Suggested fix: add paraphrase examples to the Knowledge Base document on returns, and tell the agent in the system prompt to search more widely before saying it does not know
  • Owner: the support engineering lead
  • Expected impact: the sessions flagged for this failure in the last week
  • Status: open

CI regression check: keeping the fix in place

On Growth and above, you can turn the fixed Issue into an evaluator and run it in your CI pipeline before every deploy:

Example · text
// Example: POST /api/intelligence/checks/run
POST https://api.prism.blockconvey.com/api/intelligence/checks/run?project_id=YOUR_PROJECT_ID
X-PRISMtrace-Key: pt-sk-...
Content-Type: application/json

{
  "build": "a1b2c3d",
  "replies": [
    { "input": "How long do I have to return something?", "output": "You have 30 days from the delivery date to return most items." },
    { "input": "Can I return after 60 days?", "output": "Our standard return window is 30 days, but exceptions apply for defective items." }
  ]
}

PRISM judges each reply against each check and answers with passed, which is false when any reply fails any check or could not be checked. 1 credit per reply per check; nothing is stored.

Trace ingestion and automatic scoring are available on the Free plan. Root-cause runs and fix attempts use credits (5 each). The recommendations themselves cost nothing. See AI agent evaluation and quality checks for the full feature reference.

If you want to run this workflow on your own agent, connect it to PRISM and run your first root-cause analysis.

Common mistakes

1. Treating a 200 status as success

A successful HTTP response means the call completed. It says nothing about whether the agent did what the user needed. Teams that rely on status codes and error rates miss the entire category of quality failures, wrong answers, unhelpful responses, misunderstood intent, that account for many agent problems in production.

Fix: score every response, not just the ones that error. Satisfaction and quality scores catch failures that status codes don't.

2. Fixing a single trace instead of a cluster

Debugging one bad response tells you what went wrong once. It doesn't tell you how many sessions share the same problem, or whether fixing it will make a meaningful difference. Teams that work trace-by-trace often fix the same underlying problem multiple times without realizing it.

Fix: cluster failing traces before you start fixing. If 40 sessions share a cause, the fix is worth making. If it's one, it might be noise.

3. Shipping a prompt change without replay

Editing the system prompt and deploying it is fast. Knowing whether the edit actually fixed the traces that were failing, without breaking anything else, requires replaying those traces against the new version first.

Fix: run a fix attempt before merging. PRISM replays the failing traces against the patch and opens a draft pull request only if at least 80% pass. If the number is lower, the change isn't ready.

4. Not versioning prompt changes

Prompt edits that aren't tracked can't be rolled back, can't be compared, and can't be attributed. If a change makes things worse, the team has no clean way to find out what changed or undo it.

Fix: use versioned, diffable prompt management. Every change should be attributed to a named person and reversible.

5. Skipping the before-and-after pass rate comparison

Merging a fix and moving on means you never know whether it held in production. The replay set might have passed, but new traffic could expose the same failure in a slightly different form.

Fix: check the 7-day pass rate comparison after the merge. That's your signal that the fix is working on real users, not just the traces you replayed.

How do I find what caused an AI agent failure?

Examine the prompt, retrieval context, tool calls, and agent state across the failing cluster; patterns in those fields point to the cause.

In practice, the causes fall into a short list: the prompt, a missing or unindexed document in the Knowledge Base, a retrieval gap (the document exists but isn't being surfaced), stale state, a tool call that used the wrong parameter, a guardrail configuration, or a step in the agent's workflow. Root-cause analysis checks each of these against the traces in the cluster and names the most likely one.

One-off debugging sessions rarely surface recurring causes. The signal is in the pattern across sessions, not in any single trace.

What is an AI remediation workflow?

An AI remediation workflow is a repeatable process for detecting, diagnosing, fixing, and validating agent failures. It ensures fixes are consistent, traceable, and verifiable.

The sequence applied every time a category of agent failure appears in production: detect failing traces, cluster them by similarity, trace each cluster to its cause, make the change, replay the failing traces against the fix, and compare pass rates before and after merging. A one-time debug session isn't a remediation workflow; the goal is a process your team runs every time a new failure pattern appears.

The continuous loop looks like this: create a scenario, run the agent, find the issue, observe traces and sessions, analyze patterns, evaluate with checks, remediate, run it again. Each pass through the loop should leave the agent in a better state than the last.

How do I stop fixed AI failures from coming back?

Convert the fixed Issue into an evaluator and run it in your CI pipeline so every build verifies the fix is still in place.

On Growth and above, PRISM's "Turn into an evaluator" option does this directly. Your CI pipeline sends a sample of replies to POST /api/intelligence/checks/run. PRISM judges each reply against each check and returns passed: false if any reply fails any check or couldn't be checked. The cost is 1 credit per reply per check, with a maximum of 50 replies per call. Nothing is stored.

The result is a regression guard: the specific failure your team fixed becomes a check that runs before every deploy. See AI agent evaluation and quality checks for more on building evaluators from Issues.

Find out what's breaking your agent

Connect your agent, let automatic scoring surface the failures, and run your first root-cause analysis.

Free plan available.