AI GLOSSARY · CODING AGENTS AND CODING TOOLS
smolagents
Definition
smolagents is an open-source Python library from Hugging Face for building and running AI agents in a few lines of code. Its CodeAgent writes its actions as Python code instead of JSON tool calls.
Also called: smol agents, hugging face smolagents, smolagents library, smolagents Python.
In plain language
smolagents is a small Python toolkit, published by Hugging Face, for building AI agents: programs where a language model decides what to do next, such as searching the web or running a calculation. Its main idea is to let the model write its steps as short Python code rather than filling in a form for each tool. It works with many models, hosted or run locally. Its limitation is that code written by a model is code you did not review, so running it safely takes care. The documentation describes running it in a sandbox (an isolated environment) for that reason.
Technical definition
smolagents is an Apache-2.0 Python library. Its CodeAgent has the model write each action as a Python snippet that calls tools, which the library executes, so loops, conditionals and nested calls can sit inside one action; a ToolCallingAgent offers the usual JSON or text tool-calling instead. The docs describe sandboxed execution through Modal, Blaxel, E2B or Docker. Models are pluggable: Inference providers on the Hub, API models through LiteLLM, or local models through Transformers or Ollama. Tools can come from an MCP server, from LangChain, or from a Hub Space. The code-action idea relates to the CodeAct paper (arXiv 2402.01030), which proposes executable Python code as a unified action space.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Guide · Illustrative, not executed
How to Build an AI Agent: A Minimal Tool Loop
- What you see
- A minimal agent built in Python around a tool-use loop, using Claude's Messages API documentation, with a check that it works and notes on where it breaks.
- Why it exercises the concept
- A library such as smolagents wraps this loop. Building the loop by hand first shows what the library does for you.
Guide · Illustrative, not executed
Open-source AI agents: criteria for comparing them
- What you see
- Criteria for comparing open-source AI agents on licence, permissions, tool connections and maintenance, with a test to run for each before installing.
- Why it exercises the concept
- smolagents is published under an open-source licence and can run code. Those are the licence and permission questions this guide asks of any open-source agent.
Skill by Skill Almanac · Illustrative, not executed
mcp-server-builder 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Helps an agent design a Model Context Protocol server correctly and validates its tool manifest.
- Why it exercises the concept
- The smolagents documentation says tools can come from any MCP server. A well-designed server is one source of tools for such an agent.
Skill by Skill Almanac · Illustrative, not executed
subagent-design 47/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Decides what to delegate, then writes subagent definitions and briefs that work without the conversation.
- Why it exercises the concept
- smolagents documents multi-agent systems among its tutorials. Deciding which work to hand to a second agent is the design question this skill covers.
How it shows up when you use agents
smolagents is a library you import in Python, not an application you open. It sits in the same place as other agent frameworks: you give it a model and a list of tools, call run with a task, and it loops until the agent has an answer. The Hugging Face blog defines agents as programs where language model output controls the workflow, and describes agency as a spectrum.
Its distinctive choice is the code agent. Instead of emitting a JSON blob per tool call, the model writes a Python snippet, and the library runs it. The documentation notes this is agents that write their actions in code, not agents used to write code. The docs also offer a ToolCallingAgent for the usual JSON style, and a command-line tool for running agents without boilerplate.
What breaks when this is misunderstood: model-written code runs on your machine unless you isolate it. The documentation points to sandboxed execution through Modal, Blaxel, E2B or Docker. Before you run a code agent against real files or credentials, set that up, and keep secrets out of the environment it can reach.
Tools can come from an MCP server, from LangChain or from a Hub Space, so existing connectors may be reusable. Next action: run the quickstart with no tools, read what the agent wrote, then add one tool.
Common confusions
- smolagents versus a coding agent. smolagents is a library for building agents. A coding agent such as Claude Code is a finished tool that edits your repository.
- Code agent versus agent that writes code. In smolagents a code agent writes its own actions as code. That differs from an agent whose task is to write software.
- smolagents versus the Transformers library. The blog describes smolagents as the successor to transformers.agents. They are separate packages.
- Myth: model-agnostic means model-free. The library works with many models, but an agent still needs one, hosted or local, and its quality depends on that model.
Related terms
More in Coding agents and coding tools
Sources
- smolagents documentation, Hugging Face (accessed 2026-11-24)
- huggingface/smolagents (GitHub repository), Hugging Face (GitHub) (accessed 2026-11-24)
- Introducing smolagents, a simple library to build agents, Hugging Face (accessed 2026-11-24)
- Executable Code Actions Elicit Better LLM Agents, arXiv (accessed 2026-11-24)
Definitions are written by Skill Almanac from these sources. An independent review of the sources and examples is in progress. Wikipedia is never the only source.
Review record
Independent review in progress
Drafted by claude-sonnet-5-5. An independent review of its sources and examples is in progress.
This entry is still in review, so it is not listed in search engines yet.
Change log (3)
- : First version.
- : Verifier pass: applied verifier corrections to unsourced or overstated claims.
- : Corrected explicit MCP-server anchor; link-only verification does not assert complete content approval.