Skip to main content

Choose a setup method

Start with one method for a call path. Combining SDK tracking with framework OpenTelemetry on the same call can create duplicate interactions.
Recommended. Choose this path when you want your coding agent to inspect the project, select a supported transport, make the smallest instrumentation change, send a test event, and verify that it reached Agnost AI.
Install the skill once in your coding-agent environment:
Run the framework-specific prompt below from the application root. Review the resulting diff before deploying it.

Manual setup: Agnost AI SDK

Call agnost.shutdown() once when the application exits, not after each request.

Manual setup: OpenTelemetry

smolagents uses the OpenInference instrumentor openinference-instrumentation-smolagents for OpenTelemetry tracing. It traces each agent run, each step, each model call, and each tool call. Send those spans to Agnost AI with a standard OTLP exporter.

Install

The litellm extra provides LiteLLMModel, which this example uses to call Claude. Any smolagents model class works the same way.

Setup

using_attributes puts session.id and user.id on every span created inside the block. Agnost AI groups all runs with the same session.id into one conversation and attributes it to user.id. Wrap each request in its own using_attributes block with that request’s session and user. Pass reset=False to keep the agent’s memory between turns of the same session. CodeAgent is traced the same way. Call SmolagentsInstrumentor().instrument() once at startup, before any agent runs.

What appears in Agnost AI

  • Conversations: one per session_id. The raw value is kept as original_conversation_id in the conversation metadata.
  • Users: the user_id from using_attributes.
  • Messages: one turn per agent.run(...) call, from the root <agent name>.run span. The answer is the agent’s final answer. The user side shows smolagents’ run arguments as JSON, with your prompt in the task field.
  • Events: the agent run, Step N spans, model calls such as LiteLLMModel.generate with token counts, and tool calls with arguments and results.

Verify

Run one agent.run call, wait about 30 seconds, then open Conversations in Agnost AI. Confirm the conversation shows your user_id, the task and the final answer, and a tool event for get_weather with arguments and a result.

Troubleshooting

  • Nothing arrives: confirm the exporter header is X-Agnost-Org-ID and the endpoint ends in /v1/traces. Short scripts must call provider.force_flush() before they exit.
  • Each run is its own conversation, or the user is empty: the run happened outside a using_attributes(session_id=..., user_id=...) block.
  • Tool events are named SimpleTool: OpenInference names tool spans after the tool’s Python class, and every function decorated with @tool is a SimpleTool. The real tool name is in the event metadata as tool.name. Subclass Tool with a descriptive class name if you need distinct names in the events list.
  • No spans at all: call SmolagentsInstrumentor().instrument() before you create or run agents.

References

Next steps

  • Conversations: review the complete smolagents session.
  • Events: inspect agent steps, model calls, and tool calls.
  • Patterns: organize production conversations by what users wanted.