We need to build a system where agents delegate tasks to each other in a loop. I know LangGraph is built for this with its state machine approach. Does Pydantic AI have a way to handle these complex graphs, or is it only meant for simple "one-shot" agent interactions in a Software Development context?
3 answers
It actually handles this very elegantly through programmatic delegation. Instead of a visual graph, Pydantic AI lets you define "Tools" that are actually other agents. A "Manager" agent can call a "Coder" agent just like a function. For very complex cycles, they recently introduced the pydantic_graph module. This gives you the same directed-graph control as LangGraph but keeps everything as standard Python classes. The state is just a Pydantic model that gets passed around. It’s much easier to debug because you can just use a standard Python debugger to step through the "edges" of your graph without getting lost in framework-specific abstractions.
Does this approach make it harder to visualize the workflow for stakeholders who are used to seeing the LangGraph UI?
I find the "Agent-as-a-Tool" pattern in Pydantic AI much more intuitive for our junior developers to grasp compared to complex graph nodes.
I agree with Lawrence. It feels like writing standard modular code rather than learning a whole new "graph theory" syntax just to link two prompts together.
It depends on what they need to see, Franklin. While it doesn't have a built-in "drag-and-drop" UI, the integration with Logfire provides incredible real-time traces. You can see the full nesting of agent calls, costs, and token usage in a very clean dashboard. It’s more of an "observability" view than a "design" view, which I find more useful for actual production monitoring anyway.