Favicon of smolagents

smolagents

An open-source Python AI agent library that executes Python actions, supports local models through Transformers or Ollama, and offers Docker isolation.

Screenshot of smolagents website

smolagents is a Python AI agent library for developers building software that uses tools and calculations to complete tasks. Its CodeAgent writes and executes Python actions, combining tool calls with loops and conditional logic.

  • Agent types: Use CodeAgent for Python actions or ToolCallingAgent for conventional JSON or text tool calls, with support for multi-agent hierarchies.
  • Local and hosted models: Run models through Transformers or Ollama, or connect to Hugging Face inference providers, OpenAI and Anthropic through integrations such as LiteLLM.
  • Media inputs: Agents can accept images, video and audio as well as text.
  • Tools and sharing: Connect agents to MCP servers, LangChain tools and Hugging Face Spaces, or share and load agents and tools through the Hugging Face Hub as Gradio Spaces.

The library is open source under Apache 2.0. Local model inference runs on your hardware; hosted providers receive the model requests you send to them.

Code execution has its own deployment choices. Docker provides self-hosted container isolation, while E2B, Blaxel and Modal run code in managed cloud sandboxes. LocalPythonExecutor provides only best-effort mitigations and isn't a security boundary for untrusted code.

Similar to smolagents