smolagents is a Python library for building LLM-powered agents that reason and act using Python code. The core pitch: agent logic fits in roughly 1,000 lines of code (src/smolagents/agents.py), with minimal abstractions on top of raw LLM calls. The two primary agent classes are CodeAgent — which writes its actions as Python code snippets — and ToolCallingAgent, which uses the conventional JSON/text tool-call format. Both follow the ReAct (Reason + Act) loop pattern.
The library is intentionally small: pyproject.toml lists only five hard runtime dependencies (huggingface-hub, requests, rich, jinja2, pillow). Everything else (LiteLLM, transformers, Gradio, E2B, Docker, MCP, OpenAI, Bedrock, vLLM, etc.) is opt-in via extras. The package requires Python ≥ 3.10 and is currently at version 1.25.0.dev0.
README.mdpyproject.tomlsrc/smolagents/agents.py