Build an autonomous assistant that searches the web and summarizes results without manual intervention.
Create a workflow that breaks down a complex task into steps, calls multiple APIs, and combines the results automatically.
Deploy a code-writing agent that can debug scripts or generate solutions by reasoning through problems step-by-step.
Share custom agents and tools on Hugging Face Hub for others to use and build upon.
Requires OpenAI API key and valid credentials to run agents.
smolagents is a small Python library from Hugging Face for building AI "agents", programs that use a large language model (LLM) to decide what to do step by step, calling tools and inspecting results until they reach an answer. Its distinguishing idea, captured by the tagline "agents that think in code," is that the agent expresses its plan as Python code instead of as structured tool-call messages. The model writes a snippet, it runs, the agent sees the result, and the cycle repeats. The README says the core logic fits in roughly a thousand lines, with deliberately minimal abstractions on top of raw code. To make running model-generated code safer, smolagents can execute it inside sandboxed environments, Blaxel, E2B, Modal, Docker, or a Pyodide-plus-Deno WebAssembly sandbox. Agents and tools can be shared and pulled from the Hugging Face Hub. The library is model-agnostic: it works with local models through transformers or ollama, the Hugging Face inference providers, OpenAI, Anthropic, Azure OpenAI, Amazon Bedrock, and many other LLMs via a LiteLLM integration. It is also tool-agnostic, accepting tools from MCP servers, LangChain, or a Hugging Face Hub Space, and supports text, image, video, and audio inputs. A quickstart shows installing with pip, defining a CodeAgent with a web-search tool, and asking it a question. There is also a command-line entry point with smolagent for general tasks and webagent for browsing. You would use smolagents to build your own AI agent, a research assistant, a browsing bot, a custom tool-using app, in a small, hackable codebase rather than a heavy framework. The full README is longer than what was provided.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.