How huggingface/smolagents works
smolagents is a Python library for building and running multimodal, tool-using LLM agents. The principal workflow accepts a task through the Python API or CLI, lets an agent plan and request model responses, dispatches tool calls or code for execution, and returns a result while recording run steps. Major documented branches include browser agents, model and tool integrations, Hub sharing, and sandboxed code execution. Edges are limited to relationships visible in excerpts, the source index, or README; some documented integrations have unsampled implementations.
Main entry points: agents.py Agent runtime · tools.py Tool framework · remote_executors.py Remote executors · models.py Model adapters
Components 20
Agent orchestration
- Agent runtime
src/smolagents/agents.py - Run memory
src/smolagents/memory.py - Monitoring
src/smolagents/monitoring.py
Tools and execution
- Tool framework
src/smolagents/tools.py - Default tools
src/smolagents/default_tools.py - Tool validation
src/smolagents/tool_validation.py - Type hints
src/smolagents/_function_type_hints_utils.py - Local code executor
src/smolagents/local_python_executor.py - Remote executors
src/smolagents/remote_executors.py
Models and integrations
- Model adapters
src/smolagents/models.py - MCP client
src/smolagents/mcp_client.py - Multimodal types
src/smolagents/agent_types.py - Serialization
src/smolagents/serialization.py
Interfaces and run state
- CLI
src/smolagents/cli.py - Web browser agent
src/smolagents/vision_web_browser.py - Gradio interface
src/smolagents/gradio_ui.py
Other components
- User
- LLM providers
- Sandbox services
- Hugging Face Hub
Connections 22
- User → CLI: submits task
README.md - User → Agent runtime: submits task
README.md - User → Gradio interface: sends messages
- CLI → Agent runtime: runs agent
src/smolagents/cli.py - Web browser agent → Agent runtime: uses runtime
src/smolagents/vision_web_browser.py - Gradio interface → Agent runtime: streams run
src/smolagents/gradio_ui.py - Agent runtime → Model adapters: requests responses
src/smolagents/agents.py - Model adapters → LLM providers: queries model
README.md - Agent runtime → Tool framework: dispatches calls
src/smolagents/agents.py - Agent runtime → Run memory: records steps
src/smolagents/agents.py - Agent runtime → Monitoring: tracks run
src/smolagents/agents.py - Agent runtime → Local code executor: executes code
src/smolagents/agents.py - Agent runtime → Remote executors: uses executor
src/smolagents/agents.py - Remote executors → Sandbox services: runs remotely
README.md - Tool framework → Tool validation: validates tools
src/smolagents/tools.py - Tool framework → Type hints: uses type hints
src/smolagents/tools.py - Default tools → Tool framework: defines tools
src/smolagents/default_tools.py - MCP client → Tool framework: creates tools
src/smolagents/mcp_client.py - Agent runtime → Multimodal types: handles inputs
src/smolagents/agents.py - Remote executors → Serialization: serializes results
src/smolagents/remote_executors.py - Tool framework → Hugging Face Hub: loads tools
README.md - Agent runtime → Hugging Face Hub: shares agent
README.md