Integrations
smolagents (Hugging Face)
Trace Hugging Face smolagents in Muster via the SmolagentsInstrumentor.
smolagents is a minimalist, open-source AI agent framework developed by Hugging Face. Muster captures smolagents runs through the SmolagentsInstrumentor.
Setup
1. Install dependencies
%pip install langfuse 'smolagents[telemetry]' opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents2. Configure credentials
import os
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_BASE_URL"] = "https://app.getmuster.io"
os.environ["HF_TOKEN"] = "hf_..."3. Initialize the client
from langfuse import get_client
langfuse = get_client()
if langfuse.auth_check():
print("Muster client is authenticated and ready!")4. Instrument smolagents
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
SmolagentsInstrumentor().instrument()After this, every CodeAgent / ToolCallingAgent run is captured as a
trace with sub-spans for every tool call and LLM invocation.
Add user/session attributes
from langfuse import propagate_attributes
with propagate_attributes(user_id="user_123", session_id="sess_abc", tags=["smolagents"]):
# run your smolagent
...Troubleshooting
- Enable debug logging:
export LANGFUSE_DEBUG="True". - Call
langfuse.flush()to ensure exports complete in short-lived scripts.