Welcome to this module, where you’ll learn how to build effective agents using the smolagents library, which provides a lightweight framework for creating capable AI agents.

We’ll explore critical agent types, including code agents designed for software development tasks, tool calling agents for creating modular, function-driven workflows, and retrieval agents that access and synthesize information.

Additionally, we’ll cover the orchestration of multiple agents as well as the integration of vision capabilities and web browsing, which unlock new possibilities for dynamic and context-aware applications.

 Why Use smolagents

smolagents is one of the many open-source agent frameworks available for application development. 

CodeAgents

CodeAgents are the primary type of agent in smolagents. Instead of generating JSON or text, these agents produce Python code to perform actions. 

ToolCallingAgents

ToolCallingAgents are the second type of agent supported by smolagents. Unlike CodeAgents, which generate Python code, these agents rely on JSON/text blobs that the system must parse and interpret to execute actions. 

Tools

Tools are functions that an LLM can use within an agentic system, and they act as the essential building blocks for agent behavior. This module covers how to create tools, their structure, and different implementation methods using the Tool class or the @tool decorator. 

Agent Types in smolagents

Agents in smolagents operate as multi-step agents.

Each MultiStepAgent performs:

  • One thought
  • One tool call and execution

In addition to using CodeAgent as the primary type of agent, smolagents also supports ToolCallingAgent, which writes tool calls in JSON.

Model Integration in smolagents

smolagents supports flexible LLM integration, allowing you to use any callable model that meets certain criteria. The framework provides several predefined classes to simplify model connections:

Get started with smolagents using this starter code.

References:

[1] https://huggingface.co/docs/smolagents/index

[2]https://www.anthropic.com/engineering/building-effective-agents

[3]https://huggingface.co/docs/smolagents/tutorials/building_good_agents

[4]https://platform.openai.com/docs/guides/function-calling?api-mode=chat

[5] https://huggingface.co/blog/smolagents

[6]https://github.com/deepkapha/AI-Agents-Course/blob/main/smolagent_starter_code.ipynb