Building AI agents: keep it simple with Python

As AI agents emerge as a key trend for 2025, many Python beginners ask me how to get started in this field. After exploring several minimalist, Python-based approaches to agent design, I would like to share my insights on where to begin.

I’ve been working with two promising lightweight frameworks: PydanticAI and smolagents, while also studying Anthropic’s documentation for building agents from scratch.

PydanticAI stands out for its structured outputs and data validation through Pydantic models – a elegant solution to the non-deterministic nature of LLM outputs. It also handles dependency and prompt injection during runtime, addressing common headaches in pure Python implementations.

For those committed to open source and working with local models like Deepseek, smolagents offers compelling advantages: multimodal capabilities and stripped-down abstractions. They’re currently launching a free course, I have reviewed the first unit, which provides solid LLM fundamentals for beginners.

Of course, there are more established players in the AI agent space that have built extensive frameworks. LangGraph (for agent orchestration), LlamaIndex, AutoGen, and CrewAI are notable examples. These platforms offer robust features and detailed documentation, making them appealing choices for larger projects. They come with their own challenges, though, such as steeper learning curves and potential overhead for simpler applications.

However, there’s a catch with most frameworks – being relatively new solutions, their APIs are likely to undergo frequent changes, leading to broken code and dependency conflicts. What’s particularly interesting is that in most cases, you don’t need a framework at all. Solutions built with Python using various LLM vendor SDKs often prove most effective: they’re simpler, easier to debug, and more maintainable.

For practical guidance, I highly recommend Anthropic’s educational materials, which include practical Python examples of common agent workflows (did you know they even have their prompting course for non-coders available in GoogleSheets?). I have also found a concise YouTube tutorial that effectively breaks down the fundamentals of coding agents from scratch – it’s worth checking out.

Update: At the beginning of March, OpenAI released a completely new framework for creating agents (replacing Swarm), which will certainly be a significant competitor to the tools described above.