Introducing Confident Monitor

Strands Agents

Use Confident AI for LLM observability and evals for Strands Agents

Overview

Strands Agents is an open-source SDK from AWS for building and running AI agents.

The integration works via OpenTelemetry. confident-trace, Confident AI's OpenTelemetry-native tracing SDK, installs its exporter on the shared global TracerProvider that Strands' built-in tracer already uses, so you only need to call init() once before running your Agent.

RuntimeRequirementsSetup
PythonPython 3.10+, strands-agents (tested with 1.54.0)Call init() before running the agent
TypeScriptNot supported—

Auto-Instrument

  1. Install Dependencies

    Run the following command to install confident-trace along with Strands and the model provider extra your agent uses (the example below uses OpenAI):

    pip install confident-trace 'strands-agents[openai]'
  2. Setup Confident AI Key

    Get your Confident AI Project API key and set it as an environment variable, or pass it to init() directly:

    export CONFIDENT_API_KEY="<your-confident-api-key>"
    export OPENAI_API_KEY="<your-openai-key>"
  3. Instrument Strands

    Call init() once at startup, before running your Agent. It installs Confident AI's exporter on the global TracerProvider so Strands' built-in tracer picks it up automatically.

    main.py
    from confident_trace import init, shutdown
    from strands import Agent
    from strands.models.openai import OpenAIModel
    
    init()
    agent = Agent(model=OpenAIModel(model_id="gpt-4.1-mini"), callback_handler=None)
    
    try:
        result = agent("Explain OpenTelemetry in one sentence.")
        print(result)
    finally:
        shutdown()
  4. Run your agent

    Execute the script to send traces to Confident AI:

    python main.py

    Done ✅. Open the Observatory in your Confident AI project to inspect the trace.

What Gets Captured

Strands agent runs are exported with their hierarchy intact, so you can follow an execution from the agent through its model and tool calls.

  • Agent execution — operation names, timing, status, input, output, and the relationships between steps.
  • Model calls — model details, input/output messages, and token usage.
  • Tool calls — tool names and their input/output.
  • Events and errors — lifecycle events and failed operations remain attached to the relevant part of the trace.

Sync, async, and streamed runs are supported. Content is controlled by Strands' telemetry configuration.

Set Trace Span Properties

Use a trace context to add properties you know before the call starts. It creates no extra span; the trace started by agent() inherits the tags, metadata, user ID, and customer ID.

main.py
from confident_trace import init, trace_context
from strands import Agent

init()

agent = Agent()

with trace_context(
    tags=["support"],
    metadata={"release": "2026-09"},
    user_id="user-42",
    customer_id="customer-7",
):
    result = agent("Explain OpenTelemetry in one sentence.")

See users and customers to set an optional display name alongside each ID, and trace context for every supported trace property and update behavior.

Instrumenting Multi-Turn

You do not need turn() when one Strands entry-point call is already one conversational turn—the integration creates that turn's trace automatically. Use turn() when you want to define the boundary yourself, such as grouping two sequential Strands calls into one turn. Reuse the same thread ID on later turns to group them into one conversation.

main.py
from confident_trace import init, turn

init()

with turn("support-turn", thread_id="chat-42"):
    context = agent("Find the relevant account details.")
    answer = agent(f"Summarize these details: {context}")

See threads for thread I/O, turn IDs, and user IDs.

Disable Strands Instrumentation

Pass init() a list of integration identifiers to opt in to only those integrations. The identifier for Strands is "strands" in Python; omit it to disable this integration. An empty list disables all automatic instrumentation:

main.py
from confident_trace import init
init(instrumentations=())
# Use ("strands",) to opt in; omit "strands" to disable it.

This disables Confident AI's automatic instrumentors. Strands may still emit its own native OpenTelemetry spans.

Next Steps

Now that your agent is traced, dive deeper into:

Need help instrumenting your application?Connect your model calls and agent workflows to Confident AITalk to an expert

Last updated on

Built byConfident AI