smolagents

Hugging Face developed smolagents as a minimalist, open-source framework for building AI agents with minimal code. The library prioritizes simplicity and efficiency, enabling developers to deploy LLM-powered agents quickly.

This guide covers capturing telemetry from smolagents applications using InteractiveAI.

Prerequisites

  • InteractiveAI account with API credentials

  • Hugging Face token


Installation

pip install interactiveai 'smolagents[telemetry]' opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents

Configuration

Set your API credentials as environment variables:

import os

# InteractiveAI credentials
# Obtain keys from Settings > API Keys in the dashboard
os.environ["INTERACTIVEAI_PUBLIC_KEY"] = "pk-ia-..."
os.environ["INTERACTIVEAI_SECRET_KEY"] = "sk-ia-..."

# Hugging Face token
os.environ["HF_TOKEN"] = "hf_..."

Initialize the client and confirm connectivity:


Enabling Trace Capture

Initialize the SmolagentsInstrumentor before your application code:


Running a smolagent

Here's an example with a manager agent orchestrating a search agent:


Enriching Traces with Context

Combine the SmolagentsInstrumentor with the InteractiveAI SDK to attach identifiers and metadata:


Trace Visibility

The InteractiveAI dashboard displays:

  • Manager and managed agent interactions

  • Tool invocations with search queries and results

  • LLM calls with prompts and completions

  • Multi-step reasoning chains

  • Token consumption and latency metrics

Last updated

Was this helpful?