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

Strands Agents emits OpenTelemetry spans for every agent run, event loop cycle, model call, and tool call, using the OpenTelemetry GenAI semantic conventions. Point its OTLP exporter at Agnost AI and set the session and user on the agent.

Install

The otel extra installs the OTLP HTTP exporter. Swap anthropic for the extra of your model provider.

Setup

Set this before Strands starts:
gen_ai_latest_experimental switches Strands to the current GenAI conventions, and gen_ai_span_attributes_only writes prompts and answers as span attributes instead of span events. With both set, Agnost AI shows each turn’s user message and answer as plain text. Without them, Strands still works, but messages show up wrapped in Strands content blocks such as [{"text": "..."}].
trace_attributes puts session.id and user.id on every Strands span. Agnost AI groups all turns with the same session.id into one conversation and attributes it to user.id. Create one Agent per user session, or set a new trace_attributes value for each session. You can also configure the exporter with the standard variables instead of arguments: set OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://otel.agnost.ai/v1/traces and OTEL_EXPORTER_OTLP_TRACES_HEADERS=X-Agnost-Org-ID=your-org-id, then call setup_otlp_exporter() with no arguments.

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 trace_attributes.
  • Messages: the user’s prompt and the agent’s final answer for each agent(...) call, from the root invoke_agent span.
  • Events: invoke_agent, execute_event_loop_cycle, chat, and execute_tool spans in a nested tree. Tool events carry the tool name, arguments, and result. Model events carry token counts.

Verify

Run one agent call, wait about 30 seconds, then open Conversations in Agnost AI. Confirm the conversation shows your user.id, a user message and an assistant answer, and a get_weather tool event 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 telemetry.tracer_provider.force_flush() before they exit, because the exporter sends in batches.
  • Each turn is its own conversation, or the user is empty: trace_attributes is missing session.id or user.id.
  • Messages look like [{"text": "..."}]: set OTEL_SEMCONV_STABILITY_OPT_IN as shown above before the process starts.
  • Model calls appear twice: the Anthropic Python SDK 2.x also emits its own anthropic.messages.create span for each API call, without message content. Set ANTHROPIC_OPEN_TELEMETRY=false to turn it off.
  • Your app already has a tracer provider: Strands writes its spans to the global tracer provider. Skip StrandsTelemetry() and add an OTLPSpanExporter for Agnost AI to the provider your app already registered.

References

Next steps

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