How to Write Clean AI Agent Code | Issue #70


Hi there,

You’ve probably noticed this by now: LLM prototypes are easy to build. But as soon as you try to turn them into actual production LLM systems… a lot more goes into it.

In this week’s video, I walk through how to structure AI agents in Python using design patterns like Chain of Responsibility, Observer, and Strategy. I’ll build a fully functional travel assistant using Pydantic AI and explore how to make your agent pipelines more maintainable, testable, and modular.

Hope you enjoy the video, and wish you a great weekend.

Cheers,

Arjan


Now available: ArjanCodes merch

If you want to grab a nice t-shirt, hoodie, hat, or even a mouse pad (yes, some people still use those!), check out our brand-new merch shop.

To celebrate the launch, you get 10% off your order by using the coupon code CLEANMERCH at checkout. Note that this offer is only valid until next Friday, September 19!

I’ll be adding more items soon, including a few special drops you definitely don’t want to miss. Stay tuned!


Do you enjoy my content on YouTube and would you like to dive in deeper?

🚀 Check out my online courses

My courses have helped thousands of developers take the next step in their careers. Check out these courses to help grow your skills and become a senior developer:

🔧 Need help with a complex codebase?

If your team is struggling with tech debt, unclear architecture, or cloud costs that keep creeping up, my team and I can help. We don’t just review, we get in and fix things. We’re only working with a few companies at a time to stay focused, so if it sounds like a fit:

Unsubscribe | Send by ArjanCodes

Wolvenplein 25, Utrecht, UT 3512 CK

The Friday Loop

Every Friday, you'll get a recap of the most important and exciting Python and coding news. The Friday Loop also keeps everyone posted on new ArjanCodes courses and any limited offers coming up.

Read more from The Friday Loop

Hi there, I have to admit, I often forget how powerful the Python standard library is. Whenever I'm working on some project, I have to remind myself to consider whether something I need is already there, ready for me to use. So, in this week’s video, I’m looking at 10 of the most useful and underrated modules in Python’s standard library, including pathlib, heapq, graphlib, and more. These tools can help you write cleaner, faster, and more maintainable code without adding a single dependency....

Hi there, If you’ve been experimenting with trying to integrate AI into your code, you’ve probably run into the same problem I have: unstructured, unpredictable output. And the other way around: how do you let AI agents interact with your own code? That’s where Pydantic AI comes in. In this week's video, I show how to use Pydantic AI to embed an LLM agent directly into your Python app: with structured input, validated output, and access to real business logic. What I love about this approach...

Hey there, We all want to grow: as developers, as professionals, as people. But there’s one habit that can keep you from reaching your full potential. I’ve struggled with it my whole career, and I’ve seen countless other developers fall into the same trap: making assumptions and never questioning them. Early in my startup days, I dismissed React because I thought it wasn’t worth my time. I was wrong. More recently, I almost ignored AI coding tools for the same reason. These moments taught me...