Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Building AI Self-Healing Agents with Python - 2026
New
17 students
Created byAdnan Waheed
Last updated 5/2026
English

What you'll learn

  • Build a production AI agent in Python from scratch — model, tools, agent loop, all wired together using the Anthropic SDK.
  • Detect and diagnose failures like production teams do — six failure modes, an execution monitor, and a diagnostician that classifies root cause.
  • Implement three real recovery mechanisms — tool self-repair, prompt self-modification with safety guards, and strategy switching when plans fail.
  • Ship with confidence — failure memory, recovery scoring, graceful degradation, human escalation, a 19-test pytest suite, and a local FastAPI server.

Course content

1 section41 lectures6h 18m total length
  • What Is an Agent, Really?7:23
  • Download Code and scripts0:15
  • Setup: Python, uv, and Anthropic6:25
  • Test our enviroment4:44
  • How to create your own tool18:06
  • what are stop_reason?13:10
  • How does tool use blocks?14:35
  • Your First Agent Loop16:10
  • What "Failure" Actually Means8:59
  • Defining taxonomy for catching errors10:22
  • The Execution Monitor13:42
  • What is a Silent Failure Detection?4:04
  • Code Silent Feature Detection18:49
  • Use silent detection in agent loop15:13
  • The Diagnostician5:44
  • writing a diagnostician17:55
  • Testing Diadnotics with cause, suggested fix9:28
  • The self-repair tool7:21
  • agent with self-repair tool8:48
  • Prompt Self-Modification14:35
  • Strategy Switching13:26
  • Creating a Short-Term Memory16:50
  • Creating a Long-Term Failure log15:49
  • Recovery Confidence Scorer12:36
  • Graceful Degradation12:16
  • Human Escalation12:34
  • Adversarial Test Suite8:50
  • Using pytest6:37
  • Test Suites - helper functions3:35
  • Test - Typos12:00
  • Test - Tool failures6:01
  • Test - Prompt conflicts5:49
  • Test - Loops5:21
  • Test - Silent failures4:57
  • Test - Recovery5:25
  • Test - All tests1:57
  • Create an Agent Server8:59
  • Testing the agent server with client8:26
  • Thank You!0:56
  • My Other courses0:02
  • Your feedback is very valuable!0:28

Requirements

  • No prior agent framework experience needed
  • We build everything from scratch.

Description

Most agent tutorials teach you to build agents that work on the happy path.

Ticker is valid. API returns 200. Model doesn't hallucinate. Tool schema hasn't changed. Input is well-formed. Everyone's polite.

Then you ship it.

And at 3am on a Tuesday, your agent is stuck in a loop calling the same broken tool 47 times, burning through your API budget, returning confidently wrong answers to your users, and you're the one who has to fix it.


This course is about the other 90% of the job.


I'm going to teach you how to build an agent that detects its own failures, diagnoses why it failed, rewrites its own broken tool calls, modifies its own system prompt, switches strategies when one approach stops working, remembers its mistakes so it doesn't repeat them, and knows exactly when to escalate to a human instead of pretending it has the answer.


Not error handling. Genuine self-correction.


Over 14 modules, you'll build every component from scratch in Python —

  • The execution monitor,

  • The silent failure detector,

  • The diagnostician,

  • The tool repair layer,

  • The prompt self-modifier,

  • The strategy switcher,

  • Session and long-term memory,

  • Recovery scoring,

  • Graceful degradation, and

  • human escalation.


Then at the end, you'll run it against an adversarial test suite — 20 deliberate attacks designed to break your agent in every way agents break in production. Typos. Flaky tools. Prompt injections. Contradictory instructions. Hallucination bait. Poisoned memory.


If your agent recovers from all 20, you ship it.


By the end of this course, you will have built something most production teams haven't figured out yet — an agent that gets harder to break every single time it fails.


Your agent will fail. Teach it to fix itself.

  1. Agents that survive production.

  2. Self-Healing AI Agents in Python.

  3. Build an agent that gets harder to break every time it fails.

    Let's build it.

Who this course is for:

  • Developers who want a deep, hands-on project that goes beyond CRUD apps and toy chatbots.
  • Engineers who have been paged at 3am because an agent confidently returned a wrong answer to a real user.
  • Backend and API developers moving into AI work who want to learn agents the right way — without hiding behind a framework's abstractions.
  • Anyone who is willing to explore real, practical AI agents buildings