← Library · Tool

Hugging Face Smolagents

Smolagents is a Python library that enables powerful AI agents which 'think in code,' meaning their actions are written as Python code snippets, offering secure execution in sandboxed environments like Docker. It is designed for developers who want to build and run agents quickly with minimal code, supporting various LLMs, modalities (text, vision, audio), and tools. Developers are excited because it's model-agnostic, tool-agnostic, and provides both CodeAgent for code-based actions and ToolCallingAgent for classic JSON/text actions, allowing for flexible agent development with a small, understandable codebase. It offers first-class support for Code Agents where the LLM engine writes its actions as Python code snippets, making it secure and allowing execution in sandboxed environments via Blaxel, E2B, Modal, or Docker. It is model-agnostic, supporting any LLM, whether it's a local transformers or ollama model, one of many providers on the Hub, or any model from OpenAI, Anthropic, and many others via LiteLLM integration. It also supports text, vision, video, and audio inputs. This library is tool-agnostic. You can use tools from any MCP server, from LangChain, or even a Hub Space as a tool, ensuring extensive integration possibilities. The library provides a generalist command `smolagent` to run a multi-step `CodeAgent` and a specific `webagent` for web-browsing tasks using helium. Its interactive mode simplifies the setup process for agent type selection, tool selection, model configuration, and task prompt input. This allows agents to perform complex actions, and tool calls are executed as Python function calls. This enables multi-agent hierarchies, remote code execution. This allows for vision models and import from tool collections.

Why it matters

Smolagents simplifies the creation and deployment of robust, code-centric AI agents, offering high flexibility and minimal overhead while working with any LLM or tool.

Library for code-first AI agents.

Learn one new AI thing every day.

Daily Deck sends you seven plain-English cards like this every morning. Free.

Start free