Problem
Tool.from_space() fails when following the Hugging Face Agents Course example due to an unexpected keyword argument (hf_token) passed to gradio_client.Client.
This appears to be a compatibility issue between smolagents and gradio_client.
Steps to reproduce
- Install
smolagents==1.26.0 and gradio_client==2.5.0.
- Run the following example from the Hugging Face Agents Course:
- The code raises a
TypeError.
from smolagents import CodeAgent, InferenceClientModel, Tool
image_generation_tool = Tool.from_space(
"black-forest-labs/FLUX.1-schnell",
name="image_generator",
description="Generate an image from a prompt"
)
model = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct")
agent = CodeAgent(
tools=[image_generation_tool],
model=model
)
Actual behavior and error logs
The following exception is raised:
Traceback (most recent call last):
File "ImportingaHuggingFaceSpaceAsaTool.py", line 3, in <module>
image_generation_tool = Tool.from_space(
"black-forest-labs/FLUX.1-schnell",
name="image_generator",
description="Generate an image from a prompt"
)
File "...\\site-packages\\smolagents\\tools.py", line 733, in from_space
return SpaceToolWrapper(...)
File "...\\site-packages\\smolagents\\tools.py", line 658, in __init__
self.client = Client(space_id, hf_token=token)
TypeError: Client.__init__() got an unexpected keyword argument 'hf_token'
After investigating, I found that the installed gradio_client.Client accepts token instead of hf_token.
Changing
Client(space_id, hf_token=token)
to
Client(space_id, token=token)
inside smolagents/tools.py resolved the issue and the example worked successfully.
Expected behavior
The example from the Hugging Face Agents Course should run successfully without requiring any modification to the smolagents source code.
Environment:
- OS: Windows 10
- Python version: 3.14.3
- Package version:
Name: smolagents
Version: 1.26.0
Name: gradio_client
Version: 2.5.0
Additional context (optional)
I encountered this issue while following the Hugging Face Agents Course:
https://huggingface.co/learn/agents-course/unit2/smolagents/tools
The issue appears to be related to the Client constructor using hf_token, while the installed gradio_client expects token.
Checklist
Problem
Tool.from_space()fails when following the Hugging Face Agents Course example due to an unexpected keyword argument (hf_token) passed togradio_client.Client.This appears to be a compatibility issue between
smolagentsandgradio_client.Steps to reproduce
smolagents==1.26.0andgradio_client==2.5.0.TypeError.Actual behavior and error logs
The following exception is raised:
After investigating, I found that the installed
gradio_client.Clientacceptstokeninstead ofhf_token.Changing
to
inside
smolagents/tools.pyresolved the issue and the example worked successfully.Expected behavior
The example from the Hugging Face Agents Course should run successfully without requiring any modification to the
smolagentssource code.Environment:
Additional context (optional)
I encountered this issue while following the Hugging Face Agents Course:
https://huggingface.co/learn/agents-course/unit2/smolagents/tools
The issue appears to be related to the
Clientconstructor usinghf_token, while the installedgradio_clientexpectstoken.Checklist