smolagents
v1.26.0 open-sourcefrom smolagents import CodeAgent, FinalAnswerStep
def on_final(step: FinalAnswerStep):
print('Final answer:', step.final_answer)
agent = CodeAgent(tools=[], model=model, step_callbacks=[on_final])
agent.run('What is 2 + 2?')
smolagents --dialog
result = agent.run('Summarize this document', return_full_result=True)
print(result.token_usage)
print(result.steps)
from smolagents.executors import DockerExecutor
with open('Dockerfile', 'rb') as f:
executor = DockerExecutor(custom_dockerfile=f)
agent = CodeAgent(tools=[], model=model, executor=executor)
agent.run('Analyze the dataset')
from smolagents import Tool
my_tool = Tool.from_hub('lysandre/hf-model-downloads')
print(my_tool.to_code_prompt())
print(my_tool.to_tool_calling_prompt())
from smolagents import MCPClient
client = MCPClient(
server_url='http://localhost:8080',
adapter_kwargs={'timeout': 30, 'verify': False}
)
from smolagents import CodeAgent, HfApiModel
model = HfApiModel()
with CodeAgent(tools=[], model=model) as agent:
result = agent.run('Compute 2 + 2')
# agent resources are released automatically on exit
from smolagents import CodeAgent, HfApiModel
model = HfApiModel()
agent = CodeAgent(tools=[], model=model)
agent.run('Print the first 5 Fibonacci numbers')
for step in agent.memory.steps:
if hasattr(step, 'code_output'):
print(step.code_output)
from smolagents import ApiWebSearchTool, ToolCallingAgent
search_tool = ApiWebSearchTool(headers={"Authorization": "Bearer <token>"})
agent = ToolCallingAgent(tools=[search_tool], model=model)
agent.run("What are the latest CVEs affecting OpenSSH?")
from smolagents import CodeAgent
agent = CodeAgent(model=model, tools=[...])
run_result = agent.run('Find the top 5 CVEs disclosed this week.')
print(run_result)
smolagents --api_base http://localhost:8000 --api_key sk-localkey
from smolagents import ToolCollection
tools = ToolCollection.from_mcp("<mcp_server_url>", trust_remote_code=True)
from smolagents import CodeAgent, HfApiModel
agent = CodeAgent(
tools=[],
model=HfApiModel(),
additional_authorized_imports=["numpy"], # numpy.random, numpy.linalg, etc. are now also authorized
)
from smolagents import CodeAgent, VLLMModel
model = VLLMModel(model_id="meta-llama/Llama-3.1-8B-Instruct")
agent = CodeAgent(tools=[], model=model)
agent.run("Summarize the OWASP Top 10 for 2024.")
from smolagents import CodeAgent, HfApiModel
agent = CodeAgent(tools=[], model=HfApiModel(), executor="docker")
agent.run("List all files in /tmp and return their sizes.")
smolagents --api-base https://my-llm-proxy.example.com/v1 --api-key $MY_API_KEY 'Summarize the latest news on AI safety'
from smolagents import CodeAgent, MLXModel
model = MLXModel('mlx-community/Qwen2.5-Coder-7B-Instruct-4bit')
agent = CodeAgent(tools=[], model=model)
agent.run('Compute the first 10 Fibonacci numbers.')
from smolagents import CodeAgent, GradioUI, HfApiModel
agent = CodeAgent(tools=[], model=HfApiModel())
GradioUI(agent).launch(share=True)
from smolagents import CodeAgent, HfApiModel
model = HfApiModel()
sub_agent = CodeAgent(tools=[], model=model, name='researcher', description='Searches and summarizes web content')
orchestrator = CodeAgent(tools=[sub_agent], model=model)
webagent "Find me a cheap train from Paris to Torino before Thursday"
agent.replay()
from smolagents import DuckDuckGoSearchTool
tool = DuckDuckGoSearchTool(ddgs_kwargs={"proxies": "http://proxy.corp:8080", "region": "us-en"})
results = tool("latest CVE disclosures")
from smolagents import TransformersModel
model = TransformersModel(
model_id="org/custom-model",
trust_remote_code=True
)
from smolagents import CodeAgent, HfApiModel
agent = CodeAgent(
tools=[],
model=HfApiModel(),
verbosity_level=2 # 0=silent, 1=normal, 2=verbose
)
agent.run('Summarize the latest CVE advisories.')
from smolagents import CodeAgent, HfApiModel
agent = CodeAgent(
tools=[],
model=HfApiModel(),
additional_authorized_imports=['*']
)
agent.run('Use the requests library to fetch and parse the NVD feed.')
from smolagents import OpenAIServerModel
model = OpenAIServerModel(
model_id="meta-llama/Llama-3-8b-instruct",
api_base="http://localhost:8000/v1",
api_key="none"
) Summary
smolagents is an open-source library that enables running agents via code, licensed under the Apache License, Version 2.0. It requires no payment to use and operates as a library imported into other code, targeting application developers. The README calls it an alternative to specialized agent frameworks, and it sits within the ai-agent-frameworks category. The project was last updated via a release badge, indicating ongoing maintenance.
What smolagents answers
What level of code is required to define agent logic?
agent logic fits in a relatively small amount of code.
What kind of dependencies are required to execute agent functions?
it operates as a library imported into existing code.
What are the prerequisites for running the agents?
the only requirement is the library being imported into code.
How easily can I adapt existing code structures?
the library is designed to fit into application code.
What is the scope of the agent's execution environment?
the agent runs within the application code where it is imported.
What is the legal framework governing usage?
it is distributed under the Apache License, Version 2.0.
Examples
Command line
No option matches that search.
| option | found in | since | description |
|---|
No option matches that search.
Values are placeholders taken from each option’s declared default. Nothing is executed here — the output shown is a recording of a run that already happened.
Release history
- v1.26.0
smolagents v1.26.0 adds Exa as a search engine option in WebSearchTool and removes the remote WasmExecutor.
└──▷ GET THIS VERSION$ git clone --branch v1.26.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.26.0
- ›Adds Exa as a supported search engine option in
WebSearchTool.
└──▷ BREAKING ON UPGRADE- !The remote
WasmExecutorhas been removed; any setup relying on it will break on upgrade.
- ›Adds Exa as a supported search engine option in
- v1.24.0
smolagents v1.24.0 adds FinalAnswerStep callbacks, additional apply_chat_template params, and a robust Python execution timeout mechanism.
└──▷ GET THIS VERSION$ git clone --branch v1.24.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.24.0
└──▷ USE ITCapture the agent's final answer in a callback — useful for logging or post-processing the result without parsing the full step stream.from smolagents import CodeAgent, FinalAnswerStep def on_final(step: FinalAnswerStep): print('Final answer:', step.final_answer) agent = CodeAgent(tools=[], model=model, step_callbacks=[on_final]) agent.run('What is 2 + 2?')- ›Adds
FinalAnswerStepas a supported type instep_callbacks, enabling callbacks that fire on the agent's final answer step. - ›Supports passing additional params to
apply_chat_template, giving callers finer control over prompt formatting. - ›Implements a robust timeout mechanism for Python code execution in the local sandbox.
- ›Coerces tool calls from external APIs into the internal
ChatMessageToolCallformat, broadening compatibility with third-party model APIs. - ›Extends the no-stop-sequence model list to support
gpt-5.2*model variants.
- ›Adds
- v1.23.0
smolagents v1.23.0 adds a dialog-mode CLI, Blaxel remote execution, custom Python executors, and exponential-backoff retries.
└──▷ GET THIS VERSION$ git clone --branch v1.23.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.23.0
└──▷ TRY ITRun an interactive multi-turn agent session from the terminal using the new dialog mode CLI.$ smolagents --dialog
- ›Adds dialog mode to the CLI (
smolagentsCLI with dialog mode), enabling interactive multi-turn conversations from the command line. - ›Supports custom Python code executors in
CodeAgent, letting practitioners plug in their own execution backend instead of the defaultLocalPythonExecutor. - ›Adds Blaxel integration as a remote code execution sandbox option for
CodeAgent. - ›Adds exponential backoff with jitter for model call retries, including automatic retry on rate-limit errors.
- ›Changes the default
InferenceClientmodel toQwen/Qwen3-Next-80B-A3B-Thinking.
+6 moreshow less
- ›Adds support for parsing
anyOftype schemas from MCP tools, broadening MCP tool compatibility. - ›Adds support for nested dict comprehensions (
dictcomp) and set comprehensions (setcomp) inLocalPythonExecutor. - ›Optimizes comprehension evaluation in
LocalPythonExecutorusing a generator-based approach. - ›Makes
additional_argsnullable for managed agents. - ›Migrates vLLM structured output from
guided_options_requesttostructured_outputs. - ›Updates final answer checks to accept the agent instance, enabling richer validation logic.
└──▷ BREAKING ON UPGRADE- !The default model used by
InferenceClientchanges toQwen/Qwen3-Next-80B-A3B-Thinking; any code relying on the previous default model will silently switch targets on upgrade. - !vLLM integration moves from
guided_options_requesttostructured_outputsfor structured output; configurations or wrappers that referenceguided_options_requestwill break.
- ›Adds dialog mode to the CLI (
- v1.22.0
smolagents v1.22.0 adds Modal remote execution, custom Dockerfiles, MCP structured output, and user-configurable model parameter overrides.
└──▷ GET THIS VERSION$ git clone --branch v1.22.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.22.0
└──▷ USE ITRetrieve the full run result — including token usage and intermediate steps — directly from a singleruncall.result = agent.run('Summarize this document', return_full_result=True) print(result.token_usage) print(result.steps)Use a custom Dockerfile in DockerExecutor to pre-install project-specific dependencies in the sandbox environment.from smolagents.executors import DockerExecutor with open('Dockerfile', 'rb') as f: executor = DockerExecutor(custom_dockerfile=f) agent = CodeAgent(tools=[], model=model, executor=executor) agent.run('Analyze the dataset')- ›Adds
return_full_resultparameter directly to the agentrunmethod, enabling callers to retrieve the fullRunResultobject inline. - ›Adds support for custom Dockerfile in
DockerExecutor, letting users supply their own build context instead of the default image. - ›Adds support for user-configurable parameter overrides for model completion parameters, allowing callers to override defaults passed to the underlying model completion call.
- ›Adds
ModalRemoteExecutorfor running agent code on Modal's remote infrastructure. - ›Adds support for MCP structured output and output schema in MCP tool integrations.
+2 moreshow less
- ›Makes
RunResultJSON-serializable, enabling downstream logging and persistence pipelines. - ›Supports
e2b-code-interpreterv2 in E2BExecutor.
- ›Adds
- v1.21.0
smolagents v1.21.0 adds Tool prompt methods, model_kwargs support for TransformersModel, Amazon Bedrock API key auth, and hardened LocalPythonExecutor.
└──▷ GET THIS VERSION$ git clone --branch v1.21.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.21.0
└──▷ USE ITGenerate a prompt string from a Tool object to inspect or inject its description into a custom prompt.from smolagents import Tool my_tool = Tool.from_hub('lysandre/hf-model-downloads') print(my_tool.to_code_prompt()) print(my_tool.to_tool_calling_prompt())- ›Adds
model_kwargspass-through toTransformersModelfor fine-grained inference control. - ›Adds to_code_prompt() and to_tool_calling_prompt() methods to Tool for generating prompt representations of tools.
- ›Adds Amazon Bedrock API key authentication support to
AmazonBedrockServerModel. - ›Supports passing plain
dictmessages as direct input to models. - ›Hardens
LocalPythonExecutorsecurity by blocking dunder (double-underscore) method calls.
+2 moreshow less
- ›Resets agent memory when the clear button is clicked in
GradioUI. - ›Uses
gr.Numberfor integer and number type components inlaunch_gradio_demofor more accurate input handling.
└──▷ BREAKING ON UPGRADE- !The deprecated
grammarparameter has been removed. - !The deprecated token count attributes have been removed.
- !The deprecated agent
logsattribute has been removed. - !The deprecated default
ssetransport has been removed.
- ›Adds
- v1.20.0
smolagents v1.20.0 adds a remote Python WasmExecutor, post-planning callbacks, rate limiting across API models and search tools, and image output for Tool.from_space.
└──▷ GET THIS VERSION$ git clone --branch v1.20.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.20.0
└──▷ USE ITPass custom adapter kwargs to MCPClient when connecting to an MCP server that requires non-default transport options.from smolagents import MCPClient client = MCPClient( server_url='http://localhost:8080', adapter_kwargs={'timeout': 30, 'verify': False} )- ›Adds
adapter_kwargsparameter to MCPClient for passing custom adapter configuration. - ›Adds
CodeOutputclass as an analog toToolOutputfor structured code output from agents. - ›Adds
ApiWebSearchToolto the public__all__export list, making it directly importable from the package. - ›Adds import validation in the
LocalPythonExecutorconstructor, checking authorized imports at instantiation time rather than at execution time. - ›Enforces type annotations on
ChatMessageroles via theMessageRoleenum.
+8 moreshow less
- ›Implements a remote Python
WasmExecutorfor sandboxed, browser-compatible agent code execution. - ›Supports callbacks after the planning step via
step_callbacks, extending the existing callback mechanism. - ›Supports multiple callbacks per step type in the
step_callbacksdict. - ›Implements rate limit mechanism in
ApiWebSearchToolandDuckDuckGoSearchTool. - ›Sets a default
api_key_nameinApiWebSearchTool, reducing required configuration. - ›Enables image output for tools created via
Tool.from_space. - ›Supports multiple types in tool argument validation, allowing union-typed inputs.
- ›Allows markdown or custom formatting for code blocks in agent output.
- ›Adds
- v1.19.0
smolagents v1.19.0 adds managed-agent support in ToolCallingAgent, context-manager cleanup, GradioUI memory reset, and CodeAgent output tracking.
└──▷ GET THIS VERSION$ git clone --branch v1.19.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.19.0
└──▷ USE ITClean up agent resources deterministically at the end of a task using a context manager.from smolagents import CodeAgent, HfApiModel model = HfApiModel() with CodeAgent(tools=[], model=model) as agent: result = agent.run('Compute 2 + 2') # agent resources are released automatically on exitInspect intermediate code execution results stored in each step after a CodeAgent run.from smolagents import CodeAgent, HfApiModel model = HfApiModel() agent = CodeAgent(tools=[], model=model) agent.run('Print the first 5 Fibonacci numbers') for step in agent.memory.steps: if hasattr(step, 'code_output'): print(step.code_output)- ›Supports
reset_agent_memoryinGradioUI, letting users clear conversation history from the UI between sessions. - ›Stores
CodeAgentcode outputs inActionStep, making intermediate code execution results available for downstream inspection. - ›Supports managed agents in
ToolCallingAgent, enabling multi-agent orchestration through the tool-calling interface. - ›Supports context managers for agent cleanup, allowing
withblocks to reliably tear down agent resources. - ›Transfers streaming event aggregation off the Model class, enabling more flexible streaming architectures.
- ›Supports
- v1.18.0
smolagents v1.18.0 adds parallel tool calls, streaming output, and a new ApiWebSearchTool to ToolCallingAgent
└──▷ GET THIS VERSION$ git clone --branch v1.18.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.18.0
└──▷ USE ITUse the new ApiWebSearchTool to give an agent live web search capability via API, with a custom header for authentication.from smolagents import ApiWebSearchTool, ToolCallingAgent search_tool = ApiWebSearchTool(headers={"Authorization": "Bearer <token>"}) agent = ToolCallingAgent(tools=[search_tool], model=model) agent.run("What are the latest CVEs affecting OpenSSH?")- ›Adds
ApiWebSearchToolclass for structured web search capabilities via API, with support for custom headers and params. - ›Adds configurable
tool_choicesupport inprepare_completion_kwargsfor fine-grained control over model tool selection. - ›Enables
ToolCallingAgentto execute multiple tool calls in parallel, improving performance on complex multi-tool tasks. - ›Adds streaming output support to
ToolCallingAgentfor improved responsiveness during multi-step tool interactions. - ›Adds support for passing additional params to MLXModel load and
tokenizer.apply_chat_template.
+1 moreshow less
- ›Makes
Agent.system_prompta read-only property.
- ›Adds
- v1.17.0
smolagents v1.17.0 adds structured generation in CodeAgent, RunResult from Agent.run(), and streamable HTTP MCP server support.
└──▷ GET THIS VERSION$ git clone --branch v1.17.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.17.0
└──▷ USE ITCapture rich execution metadata after an agent run to inspect results programmatically.from smolagents import CodeAgent agent = CodeAgent(model=model, tools=[...]) run_result = agent.run('Find the top 5 CVEs disclosed this week.') print(run_result)- ›Adds optional structured generation to
CodeAgentviause_structured_outputs_internally, enabling more reliable and consistent code generation patterns. - ›Agent.run() now returns a
RunResultobject, providing richer metadata about agent execution. - ›Adds support for streamable HTTP MCP servers, expanding compatibility beyond standard MCP implementations.
- ›Improves LaTeX rendering in
GradioUIwith extended delimiter support.
└──▷ BREAKING ON UPGRADE- !The deprecated
from_hf_apimethods have been removed.
- ›Adds optional structured generation to
- v1.16.0
smolagents v1.16.0 adds Bing search, custom executor functions, code timeouts, and local web agent CLI support
└──▷ GET THIS VERSION$ git clone --branch v1.16.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.16.0
└──▷ TRY ITRun a web agent locally against a self-hosted or third-party OpenAI-compatible endpoint instead of Hugging Face Inference.$ smolagents --api_base http://localhost:8000 --api_key sk-localkey
- ›Adds
executor_kwargsparameter toLocalPythonExecutorfor initialization customization of the local Python executor. - ›Adds timeout mechanism for code execution in the local Python executor.
- ›Enables local web agents via
api_baseandapi_keyCLI arguments. - ›Supports passing custom functions to the local Python executor.
- ›Adds Bing as a supported search engine in
WebSearchTool.
+1 moreshow less
- ›Changes the default value of the
providerargument inInferenceClientModelfrom'hf-inference'to'auto', automatically selecting the first available provider per the user's configured priority.
└──▷ BREAKING ON UPGRADE- !The default value of the
providerargument inInferenceClientModelhas changed from'hf-inference'to'auto'; existing setups relying on thehf-inferenceprovider by default will now use whichever provider is ranked first in the user's inference-provider settings at https://hf.co/settings/inference-providers.
- ›Adds
- v1.15.0
smolagents v1.15.0 adds streaming model output, a LiteLLM Router model, and a new WebSearchTool.
└──▷ GET THIS VERSION$ git clone --branch v1.15.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.15.0
- ›Adds
LiteLLMRouterModelto support LiteLLM Router as a model backend, enabling load-balanced or fallback routing across LLM providers. - ›Adds
WebSearchTool, replacingDuckDuckGoSearchToolas the recommended built-in web search tool. - ›Adds streaming model output support, including streaming Gradio chatbot outputs; introduces
ChatMessageStreamDeltaas the stream delta type. - ›Moves MCPClient to the root-level library and manages its dependencies as optional.
└──▷ BREAKING ON UPGRADE- !
CompletionDeltais renamed toChatMessageStreamDelta; code referencingCompletionDeltawill break.
- ›Adds
- v1.14.0
smolagents v1.14.0 adds MCPClient for MCP server connections, Amazon Bedrock native support, and star-pattern import authorization.
└──▷ GET THIS VERSION$ git clone --branch v1.14.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.14.0
- ›Adds MCPClient class to manage connections to one or more MCP servers, enabling flexible multi-server integration within smolagents.
- ›Introduces star-pattern-based import authorization for fine-grained control over which modules agents are permitted to import, improving sandboxed execution security.
- ›Adds
client_kwargspass-through for VLLMModel to supply model client parameters to the underlying vLLM client. - ›Adds
api_keyargument toHfApiModel/InferenceClientModelfor explicit key configuration. - ›Implements
Tool.from_dictandAgent.from_dictfor deserializing tools and agents from dictionary representations.
+4 moreshow less
- ›Supports Literal type annotations in the
@tooldecorator for defining enum-constrained arguments. - ›Adds custom Docker image support and enhanced configuration options for
DockerExecutor. - ›Makes
MultiStepAgentan abstract class, enabling cleaner subclassing for custom agent types. - ›Supports class docstrings and annotated assignments in
LocalPythonExecutor, broadening the Python syntax handled during sandboxed code execution.
└──▷ BREAKING ON UPGRADE- !
HfApiModelis renamed toInferenceClientModel; any code importing or instantiatingHfApiModelby that name will break.
- v1.13.0
smolagents v1.13.0 adds agent interruption, image observation logging in the Gradio UI, and automatic submodule import authorization.
└──▷ GET THIS VERSION$ git clone --branch v1.13.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.13.0
└──▷ USE ITLoad an MCP tool collection while explicitly trusting remote code — useful when working with third-party MCP servers.from smolagents import ToolCollection tools = ToolCollection.from_mcp("<mcp_server_url>", trust_remote_code=True)Authorize a top-level package and rely on automatic submodule authorization instead of listing every subpackage.from smolagents import CodeAgent, HfApiModel agent = CodeAgent( tools=[], model=HfApiModel(), additional_authorized_imports=["numpy"], # numpy.random, numpy.linalg, etc. are now also authorized )- ›Adds
trust_remote_codeparameter toToolCollection.from_mcpfor controlling remote code trust when loading MCP tool collections. - ›Authorizes submodule imports automatically when a top-level package is listed in
additional_authorized_imports— e.g.additional_authorized_imports=["numpy"]now also permitsnumpy.randomand other subpackages without listing each one explicitly. - ›Adds agent interruption support, allowing a running agent to be interrupted mid-execution.
- ›Gradio UI now logs images observed by the agent during a run, making multimodal agent traces visible in the interface.
- ›Exposes the underlying Gradio app object so users can retrieve and customize it directly.
+3 moreshow less
- ›Adds
WikipediaSearchToolto the default tools available in smolagents. - ›Introduces distinct
AgentToolCallErrorandAgentToolExecutionErrorexception types, separating tool-call failures from tool-execution failures. - ›Streaming run now yields
PlanningSteps, making planning activity visible during streamed agent runs.
- ›Adds
- v1.12.0
smolagents v1.12.0 adds MCP SSE server support and cuts planning step model calls in half.
└──▷ GET THIS VERSION$ git clone --branch v1.12.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.12.0
- ›Adds support for MCP SSE servers, enabling agents to connect to Server-Sent Events-based Model Context Protocol tool servers.
- ›Reduces model calls in
planning_stepfrom 2 to 1, halving LLM API usage per planning cycle.
- v1.11.0
smolagents v1.11.0 adds VLLMModel, tightens sandbox security with module whitelisting, and expands E2B and OpenAI server options.
└──▷ GET THIS VERSION$ git clone --branch v1.11.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.11.0
└──▷ USE ITRun an agent backed by a locally-served vLLM endpoint without leaving the smolagents API.from smolagents import CodeAgent, VLLMModel model = VLLMModel(model_id="meta-llama/Llama-3.1-8B-Instruct") agent = CodeAgent(tools=[], model=model) agent.run("Summarize the OWASP Top 10 for 2024.")- ›Adds VLLMModel class for running inference against vLLM-served models directly from smolagents.
- ›Adds
flatten_messages_as_textkwarg support toOpenAIServerModelfor controlling message serialization behavior. - ›Supports passing arbitrary kwargs to E2BExecutor Sandbox constructor, unlocking full E2B sandbox configuration from the agent layer.
- ›Forbids all modules by default in the local executor except those explicitly listed in
authorized_imports, hardening sandboxed code execution. - ›Forbids access to all dunder attributes by default in the local executor, closing a class of sandbox escape vectors.
+4 moreshow less
- ›Switches dangerous-code detection from pattern matching to module-level checking, improving accuracy of sandbox security enforcement.
- ›Adds
mlx-lmto theallextras group, making Apple Silicon local inference available via a single install target. - ›Raises agent generation errors as exceptions instead of silently swallowing them, making failure modes visible to callers.
- ›Logs agent thoughts when
verbosity_levelis set to high, giving practitioners full reasoning traces during debugging.
└──▷ BREAKING ON UPGRADE- !Default
model_idis removed from all model classes — callers that previously relied on the default must now pass an explicitmodel_id. - !All modules are now forbidden in the local executor by default; only those in
authorized_importsare allowed — existing agents that imported modules without declaring them inauthorized_importswill break.
- v1.10.0
smolagents v1.10.0 adds a Docker sandbox executor, Serper search support, custom final-answer handling, and
--api-base/--api-keyCLI arguments.└──▷ GET THIS VERSION$ git clone --branch v1.10.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.10.0
└──▷ USE ITRun an agent in a Docker sandbox to isolate arbitrary code execution from the host environment.from smolagents import CodeAgent, HfApiModel agent = CodeAgent(tools=[], model=HfApiModel(), executor="docker") agent.run("List all files in /tmp and return their sizes.")Point the smolagents CLI at a self-hosted or third-party OpenAI-compatible endpoint without editing config files.$ smolagents --api-base https://my-llm-proxy.example.com/v1 --api-key $MY_API_KEY 'Summarize the latest news on AI safety'
- ›Adds
executor="docker"argument to agent initialization, running generated code inside a Docker sandbox for isolated execution. - ›Adds
--api-baseand--api-keyarguments to the CLI for configuring model endpoints directly from the command line. - ›Adds support for Serper as a search backend, expanding the available web-search tools.
- ›Enables custom
final_answerhandling inCodeAgentand via agent__init__, letting callers override how the agent surfaces its final result. - ›Hardens the local Python interpreter by blocking access to builtins and dangerous modules at return time, reducing sandbox-escape risk without additional configuration.
+1 moreshow less
- ›Supports running an Open DeepResearch demo, including compatibility with models beyond
o1and Python ≥ 3.13 dependencies.
- ›Adds
- v1.9.0
smolagents v1.9.0 adds MLX model support, agent sharing, Gradio share passthrough, and a PromptTemplates typed dict.
└──▷ GET THIS VERSION$ git clone --branch v1.9.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.9.0
└──▷ USE ITRun a smolagents CodeAgent on Apple Silicon using a local MLX-format model for fully offline, GPU-accelerated agentic workflows.from smolagents import CodeAgent, MLXModel model = MLXModel('mlx-community/Qwen2.5-Coder-7B-Instruct-4bit') agent = CodeAgent(tools=[], model=model) agent.run('Compute the first 10 Fibonacci numbers.')Share an agent's Gradio UI publicly (e.g., for a demo or remote colleague) by passing the Gradio share flag through.from smolagents import CodeAgent, GradioUI, HfApiModel agent = CodeAgent(tools=[], model=HfApiModel()) GradioUI(agent).launch(share=True)
- ›Adds MLXModel class, enabling local inference on Apple Silicon via the MLX framework.
- ›Adds
shareparameter passthrough for Gradio, allowing agents to be exposed via a public Gradio link. - ›Adds
PromptTemplatestyped dict, providing structured, type-checked prompt template definitions. - ›Adds 'Share full agents' capability, enabling agents to be published and shared with others.
- ›Adds default value for
max_new_tokensparameter inTransformersModel, removing the requirement to set it explicitly.
+3 moreshow less
- ›
LiteLLMModelnow auto-detects message flattening requirements based on model information. - ›Extends the sandboxed Python interpreter to support non-bool comparison operators (e.g., returning non-boolean values from comparisons).
- ›Plan user prompt moved to YAML, making plan prompt customization accessible via configuration.
- v1.8.0
smolagents v1.8.0 adds agent tree visualization, simplified managed agents via name/description attributes, and Open Deep Research.
└──▷ GET THIS VERSION$ git clone --branch v1.8.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.8.0
└──▷ USE ITTurn any agent into a managed agent without wrapping it in the now-removed ManagedAgents class.from smolagents import CodeAgent, HfApiModel model = HfApiModel() sub_agent = CodeAgent(tools=[], model=model, name='researcher', description='Searches and summarizes web content') orchestrator = CodeAgent(tools=[sub_agent], model=model)
- ›Agents now accept
nameanddescriptionattributes directly to function as managed agents, replacing the removedManagedAgentsclass. - ›New visualization method to display an agent's structure as a tree.
- ›Releases Open Deep Research as a built-in example/capability.
└──▷ BREAKING ON UPGRADE- !The
ManagedAgentsclass has been removed; agents must now be configured as managed agents by settingnameanddescriptionattributes directly on the agent object. - !The
prompts_pathargument has been deleted; useprompt_templatesinstead.
- ›Agents now accept
- v1.7.0
smolagents v1.7.0 adds
smolagentandwebagentCLI commands, a persistentmemoryattribute, and an agent.replay() function.└──▷ GET THIS VERSION$ git clone --branch v1.7.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.7.0
└──▷ TRY ITQuickly kick off a web research task from the terminal without writing any Python.$ webagent "Find me a cheap train from Paris to Torino before Thursday"Replay the last agent run to inspect its reasoning steps without triggering new LLM calls.agent.replay()
- ›Adds
smolagentCLI command to run agents directly from the terminal (e.g.smolagent "Your task!"). - ›Adds
webagentCLI command to launch a web browser agent from the terminal (e.g.webagent "Find me a cheap train from Paris to Torino before Thursday"). - ›Adds a
memoryattribute to agents for persistent storage of run history across steps. - ›Adds agent.replay() method to replay the last agent run from stored memories without making additional LLM calls.
- ›Code execution outputs are now stored to memory even when an error is raised later, improving
CodeAgentperformance.
+1 moreshow less
- ›Supports third-party inference providers in
HfApiModel.
- ›Adds
- v1.6.0
smolagents v1.6.0 adds VLM auto-detection, DuckDuckGo kwargs, richer Gradio chatbot metrics, and makes transformers an optional dependency.
└──▷ GET THIS VERSION$ git clone --branch v1.6.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.6.0
└──▷ USE ITPass custom DDGS options (e.g. a proxy or region) directly through the tool constructor instead of patching the client manually.from smolagents import DuckDuckGoSearchTool tool = DuckDuckGoSearchTool(ddgs_kwargs={"proxies": "http://proxy.corp:8080", "region": "us-en"}) results = tool("latest CVE disclosures")- ›Adds
ddgs_kwargsparameter to theDuckDuckGoSearchToolconstructor, allowing callers to pass arbitrary keyword arguments to the underlying DDGS client. - ›Adds additional parameters support for the OpenAI client integration.
- ›Adds kwargs passthrough to
gradio launch, enabling full control over Gradio server startup options. - ›
TransformersModelnow auto-detects Vision-Language Models (VLMs), removing the need for manual configuration when loading a VLM. - ›Makes
transformersan optional dependency, reducing the mandatory install footprint for users who do not need local transformer inference.
+1 moreshow less
- ›Gradio chatbot now displays step duration, step number, and token counts, and supports rendering nested thoughts.
- ›Adds
- v1.5.0
smolagents v1.5.0 adds VLM support, Azure OpenAI integration, and tightened local interpreter security
└──▷ GET THIS VERSION$ git clone --branch v1.5.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.5.0
- ›Adds Azure OpenAI support as a model backend.
- ›Adds VLM (vision-language model) support, enabling agents to process image inputs.
- ›Hardens local interpreter security: builtin functions are now blocked unless explicitly added as tools.
- ›Supports
anyandnonetool types in tool call handling.
- v1.4.1
smolagents v1.4.1 adds MCP server support via ToolCollection, kwargs passthrough to all models, and new TransformersModel options.
└──▷ GET THIS VERSION$ git clone --branch v1.4.1 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.4.1
└──▷ USE ITLoad a model that requires custom remote code, such as a fine-tuned model with non-standard architecture.from smolagents import TransformersModel model = TransformersModel( model_id="org/custom-model", trust_remote_code=True )- ›Adds
trust_remote_codeargument toTransformersModelfor loading custom model code from remote repositories. - ›Adds MCP (Model Context Protocol) server support via
ToolCollection, making thousands of MCP-compatible tools usable with smolagents. - ›Allows passing arbitrary kwargs to all model classes, enabling fine-grained control over inference parameters at call time.
- ›Makes the
openaipackage an optional dependency, reducing mandatory install footprint. - ›Adds a max-length parameter for
printoutputs as an agent-level setting to cap verbose tool output.
+1 moreshow less
- ›Adds a resizable option to the Gradio UI component for improved usability.
- ›Adds
- v1.3.0
smolagents v1.3.0 adds OpenTelemetry tracing, multi-GPU support, wildcard imports, and granular verbosity control.
└──▷ GET THIS VERSION$ git clone --branch v1.3.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.3.0
└──▷ USE ITControl how much output an agent emits during a run — useful for CI pipelines (level 0) or deep debugging (level 2).from smolagents import CodeAgent, HfApiModel agent = CodeAgent( tools=[], model=HfApiModel(), verbosity_level=2 # 0=silent, 1=normal, 2=verbose ) agent.run('Summarize the latest CVE advisories.')Allow an agent to import any Python library inside its sandbox — helpful when tool code relies on arbitrary third-party packages.from smolagents import CodeAgent, HfApiModel agent = CodeAgent( tools=[], model=HfApiModel(), additional_authorized_imports=['*'] ) agent.run('Use the requests library to fetch and parse the NVD feed.')- ›Adds
verbosity_level=0/1/2parameter to agent initialization, replacing the oldverbose=True/Falseboolean for finer-grained log control. - ›Enables unrestricted code-sandbox imports via
additional_authorized_imports=['*']on agent initialization. - ›Adds OpenTelemetry instrumentation support for tracing and inspecting agent runs.
- ›Adds multi-GPU support for
TransformersModel. - ›Adds file upload capability to
GradioUI.
└──▷ BREAKING ON UPGRADE- !The
verbose=True/Falseagent initialization parameter is replaced byverbosity_level=0/1/2; existing code usingverbose=will need to be updated.
- ›Adds
- v1.2.0
smolagents v1.2.0 adds OpenAIServerModel, OpenTelemetry observability, Hugging Chat integration, and halves import time by dropping torch.
└──▷ GET THIS VERSION$ git clone --branch v1.2.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.2.0
└──▷ USE ITConnect smolagents to a locally running vLLM or TGI server instead of a hosted model provider.from smolagents import OpenAIServerModel model = OpenAIServerModel( model_id="meta-llama/Llama-3-8b-instruct", api_base="http://localhost:8000/v1", api_key="none" )- ›Adds
OpenAIServerModelclass, enabling use of any OpenAI-format-compatible inference server (TGI, vLLM, etc.) as a model backend. - ›Simplifies the Model base class to a single
__call__method: passingtools_to_call_fromreturns a tool call; omitting it returns a plain string. - ›Adds OpenTelemetry support for agent observability and tracing.
- ›Integrates
smolagentstools into Hugging Chat, enabling agent tool use directly from the chat interface. - ›Halves library import time by removing the
torchdependency.
- ›Adds
- v1.1.0
smolagents v1.1.0 adds
max_resultsto DDGS tool,deviceparam for TransformerModel, and broader LiteLLMModel kwargs support.└──▷ GET THIS VERSION$ git clone --branch v1.1.0 https://github.com/huggingface/smolagents.git # already have the repo? check out this version: $ git checkout v1.1.0
- ›Adds
max_resultskeyword argument to the DDGS (DuckDuckGo Search) tool to control the number of results returned. - ›Adds
deviceparameter toTransformerModelinmodels.pyfor explicit device placement. - ›Adds support for additional keyword arguments (kwargs) in
LiteLLMModel, enabling pass-through of provider-specific options. - ›Adds a warning to
CodeAgentwhen required imports are missing at runtime.
└──▷ BREAKING ON UPGRADE- !The
max_iterationsargument to agent initialization is renamed tomax_steps; any code constructing an agent withmax_iterations=...will break.
- ›Adds