smolagents vs Pydantic AI
smolagents is Hugging Face's small Apache-2.0 library whose CodeAgent writes each action as Python code, with manager agents calling managed sub-agents. Pydantic AI is a typed MIT framework: validated structured outputs, dependency injection, deferred tools and durable execution. Choose smolagents for code-acting agents and quick experiments; Pydantic AI for typed application code.
Facts side by side
| Fact | smolagents | Pydantic AI |
|---|---|---|
| Type | Framework | Framework |
| Languages / SDKs | Python | Python |
| License | Apache-2.0 | MIT |
| Pricing model | Open source, free | Open core |
| Orchestration pattern | Supervisor | Supervisor |
| GitHub stars | 29,604 (as of 2026-09-30) | 20,282 (as of 2026-09-30) |
| GitHub forks | 3,015 | 2,831 |
| Last push | 2026-09-30 | 2026-09-30 |
| Latest release | v1.26.0 | v1.107.7 |
| Repository | huggingface/smolagents | pydantic/pydantic-ai |
| Website | huggingface.co | pydantic.dev |
| Documentation | huggingface.co | pydantic.dev |
| Last verified | 2026-09-30 | 2026-09-30 |
| MCP support | Yes (checked 2026-09-30) | Yes (checked 2026-09-30) |
| A2A support | Unknown (checked 2026-09-30) | Partial (checked 2026-09-30) |
| AG-UI support | Unknown (checked 2026-09-30) | Yes (checked 2026-09-30) |
| Install verified | 2026-09-30 | 2026-09-30 |
Choose smolagents if
- You want agents that act by writing Python code, executed in a Blaxel, E2B, Modal or Docker sandbox.
- You want a small core you can read; the README states the main agent logic is under 1,000 lines.
- You want to share agents and tools through the Hugging Face Hub or a Gradio UI.
Choose Pydantic AI if
- You need validated, typed outputs and tool arguments.
- You need tool approval that survives the process (deferred tools) or durable execution on an external engine.
- You need AG-UI support, which has no documented counterpart in smolagents.
Migration notes
A smolagents ToolCallingAgent maps closely to a Pydantic AI Agent with tools. A CodeAgent has no direct equivalent: in Pydantic AI the model calls typed tools instead of writing code, so logic that lived in generated Python must become tools. managed_agents hierarchies become agent delegation through tools. Human review moves from step_callbacks on planning steps to deferred tools with requires_approval=True. Known limits to check before relying on smolagents multi-agent setups: snippet-level sandboxing (executor_type) does not support multi-agent setups per its secure execution guide, and open issues report problems with two-level managed-agent hierarchies and shared state in parallel runs. The built-in local Python executor is documented as not being a security boundary.
FAQ
What is a code agent?
In smolagents, a CodeAgent expresses each step as a Python snippet that the framework executes, instead of emitting a JSON tool call. ToolCallingAgent is the JSON-tool-call alternative.
Do both support MCP?
Yes. Both document MCP client support. A2A is unknown for smolagents and partial for Pydantic AI (through the external fasta2a package).
Are both free?
smolagents is Apache-2.0 with no paid product attached to it. Pydantic AI is MIT; Pydantic sells Logfire and enterprise support, neither required.