[BUG] CLI fails to load Hugging Face Spaces as tools due to missing required parameters in Tool.from_space() (original) (raw)
🐛 Bug Description
The CLI tool loading functionality fails when trying to load tools from Hugging Face Spaces due to incorrect number of arguments passed to Tool.from_space().
📍 Location
- File:
src/smolagents/cli.py - Line:
available_tools.append(Tool.from_space(tool_name))
🔍 Problem Details
In the run_smolagent function, when a tool name contains a forward slash ("/"), the code assumes it's a Hugging Face Space ID and attempts to load it using Tool.from_space(). However, the current implementation only passes one argument:
Line 136 in cli.py
available_tools.append(Tool.from_space(tool_name))
But the Tool.from_space() method signature requires at least 3 mandatory parameters:
| @staticmethod |
|---|
| def from_space( |
| space_id: str, |
| name: str, |
| description: str, |
| api_name: str | None = None, |
| token: str | None = None, |
| ): |
🔬 Steps to Reproduce
- Try to run the CLI with a Space ID as a tool:
python -m smolagents.cli "test prompt" --tools "black-forest-labs/FLUX.1-schnell" - The code will fail when it reaches line 136
❌ Expected vs Actual Behavior
- Expected: CLI should load the Hugging Face Space as a tool successfully
- Actual: Code fails with
TypeErrordue to missing required arguments
📄 Full Error Traceback
TypeError: Tool.from_space() missing 2 required positional arguments: 'name' and 'description'
💡 Proposed Solution
Auto-generate reasonable defaults for the missing parameters:
if "/" in tool_name: # Extract a reasonable name from the space_id space_name = tool_name.split("/")[-1].replace("-", "_") available_tools.append(Tool.from_space( space_id=tool_name, name=space_name, description=f"Tool from {tool_name} space" ))
🎯 Impact
This bug prevents the CLI from loading any Hugging Face Spaces as tools, which significantly limits the functionality advertised in the documentation.
📋 Additional Context
The Tool.from_space() method works correctly when called with all required parameters, as shown in the documentation examples. The issue is specifically in the CLI's automatic tool loading logic.