TThe Best SEO Podcast
← All frameworks
Self-MasterySebastian Chedal

Agent Failure-to-System Improvement Loop

Turn every agent mistake into a permanent system improvement

Difficulty
Moderate
Time to result
~weeks to results
Steps
6
Confidence
98%

This loop reframes agent errors as defects in the surrounding system rather than occasions to reprimand the model. When a failure appears, the operator checks whether the selected model can handle the task, then inspects the run trace, context, memory, skills, tools, errors, and fallback behavior. The goal is to discover why the system made the wrong path available or failed to make the right path obvious. If the agent bounced through failed approaches, the proven route is encoded in a skill or deterministic script. Instructions are also improved by explaining the desired outcome and why it matters, not merely listing steps. The revised system is then rerun against the same scenario. Over time, individual failures become reusable controls that improve reliability, speed, and token efficiency across future executions.

Origin

Extracted from The Best SEO Podcast during Sebastian Chedal's answer about why agents sometimes ignore explicit guardrails.

Core principles

  • 01Treat failures as system-design evidence
  • 02Diagnose traces instead of blaming the model
  • 03Fix recurring paths, not individual conversations
  • 04Use skills and scripts to remove needless exploration
  • 05Communicate goals and purpose as well as steps

How to run it

  1. 1

    Preserve the evidence

    Capture the prompt, context, model, tools, trace, outputs, and errors from the failed run. Do not rely on memory of what happened.

    Pro tip Record the system state and external dependencies involved in the failure.

    Watch out Removing evidence too early encourages superficial explanations.

  2. 2

    Check model fit

    Determine whether the model has sufficient reasoning and instruction-following ability for the task. Compare behavior with a stronger model when appropriate.

    Pro tip Use the cheapest model that reliably satisfies the job, not the cheapest model available.

    Watch out A stronger model cannot repair a fundamentally ambiguous system.

  3. 3

    Trace the path

    Review what the agent attempted, where errors occurred, and which workaround produced the bad result. Look for pinball-like exploration.

    Pro tip Ask the agent to explain which skill and tool path it used, then verify against logs.

  4. 4

    Repair the system

    Remove unnecessary choices, improve context, or encode the correct procedure in a skill or script. Strengthen state and validation controls where needed.

    Pro tip Prefer one reusable correction over repeated conversational reminders.

    Watch out Angry or more forceful prompting may change one run without preventing recurrence.

  5. 5

    Clarify purpose

    State the goal, constraints, and why the behavior matters so the model can judge shortcuts correctly. Include general success criteria rather than only test-specific values.

    Pro tip Explain invariants such as working for all valid inputs.

    Watch out Overly narrow examples can invite hard-coded solutions.

  6. 6

    Regression-test the fix

    Rerun the original case and nearby variants. Confirm that the correction works without creating a new failure path.

    Pro tip Convert important failures into permanent automated tests.

In the wild

Preventing a hard-coded test value

A coding agent makes a test pass by inserting the expected value as a magic number. Instead of scolding it, the team clarifies that the implementation must work for all valid values, inspects why the shortcut was accepted, adds a general test set, and encodes the constraint in the task workflow.

→ The system validates the intended behavior rather than rewarding a test-specific shortcut.

Common mistakes

Scolding the model

A stern correction may influence the current conversation but does not change the tools, context, or procedure that caused the failure.

Fixing only the visible symptom

Patching one output leaves the same flawed decision path available in future runs.

Teaching from one expected answer

Overly specific test instructions can encourage a model to hard-code the example instead of implementing the general requirement.

Is it for you?

Best for

Teams operating agents that make recurring errors, violate instructions, or waste tokens exploring known paths.

Not ideal for

One-off failures caused entirely by a transient external outage with no reusable corrective action.

From the transcript

“the the question isn't why is this model making this problem?”

Sebastian Chedal · 23:04

“It's what can I do to improve the system to make sure that this problem doesn't happen again, right?”

Sebastian Chedal · 23:11

“you have to really be thinking about system design.”

Sebastian Chedal · 23:32

From the episode

Agentic AI For Marketers With Sebastian Chedal

Sebastian Chedal

→