smolagents
Hugging Face's small Python library for agents that write their actions as code.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkWhat it is
smolagents keeps the agent loop to roughly a thousand lines of code. Its main idea is the CodeAgent, which writes each action as a Python snippet instead of a JSON tool call, so it can loop, branch and combine tools in one step. Because that means running model-written code, it supports sandboxed execution in services such as E2B, Modal and Docker. It works with local models, Hugging Face inference providers or any API through LiteLLM, and can load tools from MCP servers, LangChain or the Hub.
Best for
A readable agent loop you can study and modify.
Skills it helps with
Related tools
Agent Development Kit (ADK)
Google's code-first framework for building, evaluating and deploying agents.
Claude Agent SDK
Build agents on the same harness that powers Claude Code.
LangChain
Components and integrations for building LLM applications.
Microsoft Agent Framework
Microsoft's open-source framework for agents and multi-agent workflows.
OpenAI Agents SDK
Lightweight Python framework for agents, handoffs and guardrails.
Pydantic AI
Type-safe Python agent framework from the Pydantic team.