Kavvo Agents

smolagents

November 29, 2026 · 4 min read · By the Kavvo Agents team

What it is

smolagents is an open-source Python library from Hugging Face for building agents with very little code. Its docs say it is designed to make it extremely easy to build and run agents using just a few lines of code. A minimal agent needs a model, a list of tools, and a task — and that is often enough to get a working result.

The library is deliberately small. It does not try to be a full platform. It gives you two agent types, a way to define tools from ordinary Python functions, and support for many models, including Hugging Face models, local models, and models from other providers through LiteLLM. That simplicity is the point: you can read the whole library, understand what it does, and change it if you need to.

Who made it

smolagents is made by Hugging Face. The documentation is at huggingface.co/docs/smolagents, and the source is on GitHub under the huggingface organisation.

What it does

smolagents agents can search the web, run Python code, read files, call APIs, and use tools from the Hugging Face Hub, from MCP servers, from LangChain, or from a Gradio Space. Tools can be defined with the @tool decorator on a Python function, loaded from the Hub with load_tool, or grouped in a ToolCollection from a hub or MCP source.

The library provides two agent types. CodeAgent, the default, writes its tool calls in Python code. ToolCallingAgent writes its tool calls in JSON. Both inherit from MultiStepAgent, which means they act in multiple steps, each step consisting of one thought, then one tool call and execution. Agents can also manage other agents: you pass an agent a name and a description, and a manager agent can call it as a tool. Built-in tools include a Python interpreter, a final-answer tool, a user-input tool, and web search tools.

How it works

You create an agent with a model and a list of tools, then call agent.run("Your task"). The agent uses the ReAct pattern: it thinks, calls a tool, reads the result, and repeats until it can give a final answer. The maximum number of steps is set when you create the agent — the default has changed between versions, so check the docs for your version.

Models are flexible: you can use InferenceClientModel for Hugging Face Inference Providers, TransformersModel for a local model with Transformers and Torch, LiteLLMModel for more than 100 providers through LiteLLM, or OpenAIServerModel for an OpenAI-compatible server. You can also write your own model callable. The agent’s system prompt, tool descriptions, and planning interval can be customised, and you can add step callbacks to watch or log each step.

How to start

  1. Install smolagents with pip install smolagents. For extra tools, install pip install smolagents[toolkit], and for a local Transformers model, install pip install smolagents[transformers].
  2. Set up your model. For the quickstart, use InferenceClientModel, which uses a Hugging Face model by default — check the docs for whether you need a Hugging Face token for the model you choose.
  3. Write a first agent: import CodeAgent and InferenceClientModel from smolagents, create a model, create an agent with CodeAgent(tools=[], model=model), and run it with agent.run("Your question").
  4. Add a tool. Decorate a Python function with @tool, give it a clear docstring and typed arguments, and pass it in the tools list.
  5. Try a ToolCallingAgent if you want JSON tool calls instead of code, and try a managed agent when a task needs two agents.
  6. Launch a Gradio demo with the built-in helper when you want a simple web UI for testing.

Follow the quickstart on the official docs page for your version, because the API is marked experimental and changes.

Who it is for

smolagents is for Python developers who want the smallest possible agent library, and for researchers and hobbyists who want to try agents quickly. It suits prototypes, experiments, and learning, and developers who already use Hugging Face models and want an agent that can run a local model. It is not a no-code builder, and it is not a production platform on its own — you add deployment, auth, and monitoring yourself.

Watch out for

The docs warn that smolagents is an experimental API which is subject to change at any time, and that results can vary as the APIs or underlying models change. Do not build a production system on an API you have not pinned to a version. The CodeAgent writes and runs Python code, so run it in a sandbox and do not give it tools that can delete files, send messages, or spend money without approval. Costs and limits depend on the model you choose — a hosted inference model and a local model behave very differently. Finally, check the docs for your installed version: the default maximum steps, the model class names, and the tool API have all changed between releases.

Source