Skip to content

[bot] Add smolagents (HuggingFace) integration for CodeAgent and ToolCallingAgent instrumentation #352

@braintrust-bot

Description

@braintrust-bot

Summary

smolagents (smolagents) is HuggingFace's agent framework for building AI agents that write and execute Python code or use tool-calling to perform actions. It has 26.9k GitHub stars, 34 releases, and is actively maintained (latest: v1.24.0, January 16, 2026). This repository has zero instrumentation for any smolagents execution surface — no integration directory, no wrapper, no patcher, no auto_instrument() support.

smolagents provides two primary agent types: CodeAgent (agents write Python code snippets to call tools) and ToolCallingAgent (agents use standard tool-calling). Code agents achieve ~30% fewer steps and LLM calls compared to standard tool-calling on complex benchmarks. The framework supports multi-agent orchestration where agents can call other agents as tools.

Comparable agent frameworks (Agno, AutoGen, AgentScope, OpenAI Agents SDK, Claude Agent SDK, Google ADK, Pydantic AI) all have dedicated native integrations in this repository.

What needs to be instrumented

The smolagents package exposes these execution surfaces, none of which are instrumented:

Agent execution (highest priority)

Class / Method Description
CodeAgent.run() Executes an agent that writes and runs Python code to accomplish tasks
ToolCallingAgent.run() Executes an agent using standard LLM tool-calling
MultiStepAgent.run() Base class for multi-step agent execution

Each run() call involves an iterative loop where the agent:

  1. Receives the task and available tools
  2. Thinks/plans (LLM call)
  3. Generates an action (code snippet or tool call)
  4. Executes the action
  5. Observes the result
  6. Repeats until the task is complete or max steps reached

Tool execution

Class / Method Description
Tool.__call__() Individual tool invocations during agent execution
ManagedAgent Agent-as-a-tool for multi-agent orchestration

Model calls

Class / Method Description
Model.__call__() LLM calls made by agents (supports OpenAI, Anthropic, HF, local models)
HfApiModel.__call__() HuggingFace Inference API calls
LiteLLMModel.__call__() LiteLLM-backed model calls
OpenAIServerModel.__call__() OpenAI-compatible server calls

Planning steps

Class / Method Description
Agent.planning_step() Individual reasoning/action steps within a run

Implementation notes

Minimal framework: smolagents is designed to be minimal (~1,000 lines of core logic). The integration surface is correspondingly small, making it a good candidate for a lightweight integration.

Agent lifecycle: Each run() call produces a series of planning_step() calls. The integration should create a parent span for the run() and child spans for each planning step, tool call, and LLM invocation.

Code execution tracing: For CodeAgent, the generated Python code is a key piece of tracing data. The integration should capture the generated code in span metadata alongside the execution result.

Multi-agent: When agents call other agents via ManagedAgent, the integration should preserve the parent-child span hierarchy across agent boundaries.

No coverage in any instrumentation layer

  • No integration directory (py/src/braintrust/integrations/smolagents/)
  • No wrapper function (e.g. wrap_smolagents())
  • No patcher in any existing integration
  • No nox test session (test_smolagents)
  • No version entry in py/src/braintrust/integrations/versioning.py
  • No mention in py/src/braintrust/integrations/__init__.py

A grep for smolagents or smol.agents (case-insensitive) across py/src/braintrust/ returns zero matches.

Braintrust docs status

not_found — smolagents is not mentioned on the Braintrust integrations directory or the tracing guide.

Upstream references

Local repo files inspected

  • py/src/braintrust/integrations/ — no smolagents/ directory exists on main
  • py/src/braintrust/wrappers/ — no smolagents wrapper
  • py/noxfile.py — no test_smolagents session
  • py/src/braintrust/integrations/__init__.py — smolagents not listed in integration registry
  • py/src/braintrust/integrations/versioning.py — no smolagents version matrix
  • Full repo grep for "smolagents", "smol.agents" — zero matches in SDK source

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions