You’ve built an AI agent from scratch in Python, starting from a single call to an LLM. You wrapped the model in a harness, gave it short-term memory through the conversation context, described tools it could request, and closed the agentic loop so the model could chain tool calls until it had an answer. Along the way, the trace() helper showed you every message moving between you, the harness, the model, and the tools.
Many Python developers now work with agents every day, and so do more and more people who don’t write code at all. Knowing what’s happening behind the scenes helps you understand why an agent behaves the way it does, what it costs, and where it can go wrong.
In this video course, you’ve learned how to:
- Call an LLM from Python with the OpenAI library
- Wrap the model in a harness loop and trace the flow of information
- Keep conversation context by resending the
messageslist - Describe tools with a JSON schema and run the tool calls the model requests
- Close the agentic loop so the model can chain tool calls
Now, when you use an agent, you’ll know what’s going on inside it. It’s not a mystery anymore. You can extend your agent with a tool of your own or explore a framework such as Pydantic AI to build something bigger.