AI Agents for Python Developers:
Learn the Loop, Predict the Agent

AI Agents for Python Developers: Learn the Loop, Predict the Agent

Agentic Loops • 4 Hours • 2 Live Sessions

Build the loop by hand in the first hour. Spend the rest of the course watching agents do things you can now see coming.

Hosted By

Stephen Gruppetta
Stephen Gruppetta, PhD
Core Team member at Real Python and the author of Object-Oriented Programming in Python. He teaches Real Python's Intermediate Python Deep Dive cohort and brings the same hands-on approach to this course.

You use an agent most days. It mostly works.

But somewhere along the way you stopped being able to predict it:

“Why did it stop there?”

“Why did it say it was done when it wasn’t?”

“Why does it get worse after the first hour?”

You’re not the only one. We asked 62,753 developers what they were struggling with, and the answers from people already building with AI kept landing in the same place:

“I can play with llm models, agentic coding. But I don’t know the underlying things.”

“Vibe coding and not really understanding what is taking place ‘under the hood’.”

“Overreliance on coding agents, and lack of awareness of possibilities to adequately direct.”

The thing is:

You can get real work done without knowing how an agent works. Plenty of people do.

What you collect instead is folklore. Start a new session when it gets weird. Don’t let it touch more than three files. Re-paste the context and hope. Each rule works most of the time, and not one of them tells you why.

The share of our audience building with AI has gone from 10.9% to 16.3% in a year. Almost all of them are working from the same folklore.

So when something goes wrong in front of your team and somebody asks “why did it do that?”, the real answer is a guess.

It doesn’t have to be.

What Makes This Course Different

You’ll Build the Agent. Then You’ll Recognize It Everywhere.

Most agent courses start with a framework. You learn its abstractions, its decorators, its particular way of describing a tool. Then when the agent does something strange, you’re debugging the framework’s idea of an agent rather than an agent.

This one runs the other direction.

In the first hour you type out a working agent by hand. One model call. A list of messages. One tool. A while loop. It’s small enough to read in one sitting, and there is nothing hidden inside it.

Then we open Claude Code and point at where each piece you just wrote shows up. This is /compact. This is the permission prompt. This is what CLAUDE.md is doing. This is why the Task tool exists.

Nothing gets introduced before you’ve felt the problem it solves:

  • the agent runs away, and then you add a stopping condition
  • a tool swallows an error and the agent congratulates itself on nothing, and then you fix what you hand back
  • the context fills up and the answers go soft, and then you deal with memory

Halfway through, we stop writing the agent and let it extend its own code while you direct it and read every diff. It’s the codebase you wrote an hour ago, so for once you know it well enough to have a real opinion about what it did.

By the end, you won’t just know what an agent is. You’ll be able to watch one start a job and say what it’s going to do next, before it does it.

Course Curriculum

Two live 2-hour sessions on Zoom. You code along in real time, and questions are taken as they come rather than held to the end.

Session 1: The Loop, and What Goes Into It

By the end of this session, you'll have an agent you typed yourself, and you'll be able to see exactly what the model is given on every pass.

What you'll build: A working agent, by hand, from a single model call up to a loop that reads a real folder and describes the project in it.

What you'll learn:

  • Where an agent's memory actually lives, and why long chats cost more
  • Why the model never runs anything itself, and what that has to do with permission prompts
  • The three lines that turn a chatbot into an agent
  • Why it stops too early, and what "finished" means to something that can only see the last result
  • What you hand back to the model, and why a tool that hides its errors is worse than one that fails loudly

Session 2: Handing It Over

By the end of this session, you'll have directed the agent through upgrades to its own code, and read every diff it produced.

What you'll build: Memory in files, then compaction, approval gates and subagents — written by the agent, specified and reviewed by you.

What you'll learn:

  • What the context window looks like from the inside, and what happens as it fills
  • How to say what you want well enough that an agent can act on it
  • What has to survive a compaction and what can be thrown away
  • Which calls need a human in the loop, and how to decide where that line sits
  • Why a tool would contain another loop, and what a subagent is really for
  • The prediction test: five transcripts of agents behaving oddly, and you call the cause

Real Python Satisfaction Guarantee

This course is backed by Real Python's guarantee. You can receive a full refund within 14 days after the course ends, provided you meet the completion criteria in our refund policy.

What You’ll Be Able to Do

  • Watch an agent start a job and say what it's going to do next, before it does it
  • Answer "why did it do that?" by printing the message list and pointing at the reason, instead of guessing
  • Recognize when an agent is stuck after two attempts instead of twenty, and know whether to steer it or start again

What You’ll Receive

  • 2 live 2-hour sessions via Zoom
  • Cohort forum with the instructor and your peers, before and after the sessions
  • The repository, with the full git history: your commits from the first half, the agent's from the second, each one carrying the prompt that produced it
  • The decoder card: a one-page table with every piece of the loop you built next to the name it goes by in Claude Code and Codex
  • A one-page list of what to change in your own work
  • Lifetime access to the recordings and materials

Who This Course Is For

#1

Daily Agent Users who reach for Claude Code or Codex every morning and are tired of being surprised by it

#2

Workaround Collectors who keep hitting the same three walls — it forgot, it went too far, it said it was done and it wasn't — and want the reason rather than another rule of thumb

#3

The Person Who Gets Asked when an agent does something strange on their team, and would like an answer they can actually defend

Who Should Not Take This Course?

This course is about understanding the agents you already use, not building your own agent framework to ship.

It also assumes Python proficiency. You should be comfortable writing Python and reading a traceback, and you should have used an AI coding tool before. If you’re still learning Python basics, start with Real Python’s Python Basics Learning Path instead.


Meet Your Instructor

Stephen Gruppetta
Stephen Gruppetta, PhD
Core Team member at Real Python and acclaimed Python educator who combines years of teaching expertise and storytelling techniques to make complex programming concepts clear, engaging, and unforgettable.

Stephen Gruppetta is a seasoned Python educator and author known for his engaging narrative approach to explaining complex concepts, drawing on his PhD in physics and years as a lecturer and technical writer.

With experience ranging from corporate training to creating accessible resources like The Python Coding Book, he’s dedicated to helping learners master Python with clarity and creativity.

Why Learn With Real Python?

Real Python started as a Kickstarter project in 2012. Today, over 1 million developers, data scientists, and ML engineers read it every month.

Our content goes through what very few Python resources match:

  • Expert technical review for accuracy
  • Teaching specialist evaluation for learning effectiveness
  • Professional editing for clarity

Our live courses bring that same review process to an interactive, instructor-led format. You get the questions, the live discussion, and a community that’s been learning Python with us since 2012.

What Learners Say About
Stephen’s Courses

“I felt like I was a really well-studied Python beginner… But I couldn’t quite get out of there to the next level. And [Stephen's course] is helping because it’s all about that deeper understanding.”

“I can look at modules, I can look at other people’s code and I understand why they’re doing what they’re doing. And it’s not just taking things for granted anymore… I can go on and start exploring more complex things without immediately getting lost.”

— Jerry Wilson, Technical Lead at AIM EMS Software

“Ever since we’ve been taking the course, I’ve really changed a lot of the way that I’m programming.”

“It’s definitely given me more confidence to go deep dive into things I just took for granted… But after this course I feel much stronger in being able to understand the fundamentals of why things work in Python that it’s given me more confidence to go deeper.”

— Matt Thacker, Sr. Solutions Engineer at Eptura


Why This Course Works

Agents are hard to learn from documentation, because the failures are missing.

A tutorial can show you what a tool call looks like. It rarely shows you an agent congratulating itself on a tool that quietly returned nothing, which is the thing that will actually cost you an afternoon.

In this course, you get the before and after:

  • the chatbot with no memory, before the message list
  • the runaway, before the stopping condition
  • the tool that swallows its errors, before we fix what we hand back
  • the conversation that goes soft at one end, before compaction
  • the agent you steer, before you know what to say to it

You’ll see each of these happen in the session, so you’ll recognize them the first time they show up in your own work.

You’ll leave able to predict the agent you already use every day, and to say why it does what it does.

Frequently Asked Questions

You should be comfortable with Python and able to read a traceback. Specifically:

  • Writing and calling functions
  • Working with dictionaries and lists
  • Using modules, packages, and virtual environments
  • Running Python scripts from the command line

You should also have used an AI coding tool before, such as Claude Code, Codex, Cursor, or Copilot. You need no knowledge at all of how agents work internally. That’s the course.

Python 3.12 or newer, your editor of choice, and Zoom.

You’ll also need access to a model API to run your agent against. We’ll confirm the exact setup, and run a supported setup week before the course, so nobody spends the first session installing things.

Yes. You’ll keep:

  • The complete repository, with the full git history of the session
  • The decoder card
  • Session recordings
  • The one-page list of what to change in your own work

Dates and times haven’t been announced yet. Join the waitlist and you’ll be the first to hear when they are, before the course is opened up more widely.

Each session is recorded and posted shortly afterward, so you can catch up on your own schedule. We recommend attending live when you can, since the value of a live course is asking questions in real time. But if work collides with a session, the recording will be ready before the next one starts.

You code along. The first half of the course is you typing out a working agent by hand, and that’s the part everything else rests on. Watching someone else build it is a different and much weaker experience, so we’d rather you were at a keyboard.

Every cohort gets a dedicated forum that runs from before the first session through to after the last. Stephen is based in UTC+1 and monitors the forum throughout his working day, so you can ask questions, share what you’re building, and get unstuck without waiting for the next live session.

No. You build a plain-Python agent that belongs to nobody, then we point at where each piece of it shows up in the tools you already use. Claude Code and Codex are the ones we name on screen, because they’re the ones most of the room has open. What you learn applies to whichever one you’re using next year.

Yes. Select the number of seats you need on the booking page when the cohort opens. Each team member will receive their own access to the course materials and recordings.

This course is backed by Real Python’s satisfaction guarantee. You can receive a full refund within 14 days after the course ends, provided you meet the completion criteria in our refund policy.

Have another question? Email us at info@realpython.com