Pydantic AI Agents - A review

Another day, another agentic Framework released... In - oh yeah, the best language that exists - python. Seriously though, its one of the better ones.

𝗛𝗼𝘄 𝘁𝗵𝗲𝘆 𝘄𝗼𝗿𝗸:

Agents in PydanticAI are ReAct agents, so the LLMs are able to call tools (python functions), see the output and make a decision to end the conversation or make another tool (function) call.

Agents in Pydantic AI consist of 5 things:

  • A System Prompt
  • A collection of tools (functions)
  • Structured Output
  • Dependencies (other python objects)
  • LLM (Model)

Its really fast to create this type of agent, and it supports streaming and async execution straight away. I usually use LangGraph, which I prefer for its graph execution setup, however, the abstractions are much simplier for this framework and because it supports streaming I will probably be using it for anything that doesnt require (as pydantic puts it) a 'nail gun' (their grpah execution setup) over a hammer (standard agent).

𝗠𝘂𝗹𝘁𝗶-𝗔𝗴𝗲𝗻𝘁 𝗦𝘂𝗽𝗽𝗼𝗿𝘁

The framework supports two different paradigms for a multi-agent setup:

𝘿𝙚𝙡𝙚𝙜𝙖𝙩𝙞𝙤𝙣: One agent can ask a question of another agent down and back up a chain, but you cannot create cyclic graphs. This isnt a new abstraction but is supported with their simple API.

𝗚𝗿𝗮𝗽𝗵:You can create a more complex agents using their graph abstraction, which works the same way as LangGraph. The difference between this abstraction and LangGraph is that there are no explicitly defined edges with this framework, which I dont know if I am a fan of personally.You can also just join togethere their lower level API abstraction to create your own multi-agent setup.

Benefits of Pydantic:

  • Async
  • Simple and Complex Abstractions
  • Multi-agent support
  • Streaming supported
  • Structured Output can be streamed, and its all valid Json!
  • Dependency Injection into tool calls (this is reallly cool

Downsides of Pydantic:

  • No Memory or state persistence
  • Limited integrations (langchain tools not supported & limited tracking support, logfire only)
  • Mediocre documentation