smolagents is Hugging Face's small, open-source Python library for building agents. Its main idea is the CodeAgent, which writes each action as a Python snippet instead of a JSON tool call. There is also a ToolCallingAgent for the standard JSON style.
It works with local transformers and Ollama models, Hugging Face inference providers, LiteLLM, OpenAI-compatible servers, Azure and Bedrock. Tools can come from MCP servers, LangChain or Hugging Face Spaces, and you can push and load agents on the Hub.
Generated code should run in a sandbox: E2B, Blaxel, Modal or Docker are supported, and the built-in local executor is explicitly not a security boundary. Install with pip install "smolagents[toolkit]". It is Apache-2.0 licensed.