Integrations / smolagents
To trace smolagents with Tracify, wrap the call to agent.run with trace_agent and add a step to each tool. You get one trace per task, with every tool call in the order the agent made it.
Your code
smolagents
Tracify
One run.
Setup
smolagents and the Tracify SDK.
pip install tracify-sdk smolagentsCreate a project in Tracify, copy its API key and put it in the environment where your code runs. The SDK reads it from there, so nothing is hard-coded.
export TRACIFY_API_KEY="tracify_sk_live_..."Each task becomes one run. Everything recorded inside while the agent works joins it.
import tracify
@tracify.trace_agent(name="smolagent")
def run(task: str):
return agent.run(task)The agent decides which tools to call. A step in each tool function shows exactly which ones it called, with what, and what came back.
from smolagents import tool
@tool
def get_weather(city: str) -> str:
"""Return the weather for a city.
Args:
city: Name of the city.
"""
with tracify.span("get_weather", type="tool", input=city) as step:
forecast = f"Sunny in {city}"
step.set_output(forecast)
return forecastRun your code one time, then open the Tracing page of your project. Your agent task shows up as a run with its steps in order, plus the tokens, time and any error for each call.
Good to know
A CodeAgent runs Python it writes itself. The tool calls it makes still go through your tool functions, so they are recorded. The code the model wrote is not captured by these steps.
Good to know
smolagents has its own model classes, so those requests are not wrapped automatically. If your model class uses an OpenAI-style client that you create, wrap that client and the calls join the run.
Full details in the documentation. All integrations are listed on the integrations page.
