Skip to main content

Trace Strands agents with Future AGI

Send Strands' native agent, model, event-loop and tool spans to Future AGI with one OpenTelemetry exporter. The adapter preserves the native trace tree, maps content to Future AGI attributes, and counts token usage only on model spans rather than again on agent aggregates.

Install

pip install -U traceai-strands 'strands-agents[otel,openai]>=1.24.0' 'fi-instrumentation-otel>=1.2.2'
Dependency Minimum supported version
Python 3.10
Strands Agents 1.24.0

Upgrade older Strands installations to preserve explicit provider metadata on the model span and complete event-loop spans when a model call raises an ordinary error. This does not resolve the early-stream-close limitation. The example uses your own OpenAI API key; you can instead use any model supported by Strands.

Configure and run

Set FI_API_KEY, FI_SECRET_KEY, and OPENAI_API_KEY in your environment. Configure tracing before constructing an Agent, and use one global provider per process.

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from fi_instrumentation.otel import HTTPSpanExporter
from traceai_strands import StrandsSpanExporter

provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="my-strands-agent",
    set_global_tracer_provider=True,
    span_exporter=StrandsSpanExporter(
        HTTPSpanExporter(),
        capture_content=True,
    ),
)

from strands import Agent
from strands.models.openai import OpenAIModel

try:
    agent = Agent(
        model=OpenAIModel(model_id="gpt-4o-mini"),
        trace_attributes={"gen_ai.provider.name": "openai"},
        callback_handler=None,
    )
    print(agent("What is the capital of France?"))
finally:
    provider.force_flush()
    provider.shutdown()

This example explicitly enables prompt, response and tool-content capture. Omit capture_content=True to export metadata and usage without content. In a long-running service, flush and shut down the provider when the service stops, not after each request.

Open Observe in Future AGI and select my-strands-agent. An invocation contains an agent span, an event-loop span and a model span; calls to Strands tools add native tool spans. Token usage belongs to model spans, not the enclosing aggregate spans.

HTTPSpanExporter() uses both Future AGI authentication headers and sends to https://api.futureagi.com/tracer/v1/traces by default. For self-hosting, set FI_BASE_URL to your Future AGI base URL. register() supplies the required project_name and project_type resource attributes. Do not add StrandsTelemetry.setup_otlp_exporter() or a second raw exporter to this pipeline: it would export another copy outside the adapter's privacy policy. Future AGI accepts traces, not Strands metrics or logs.

Control content capture

StrandsSpanExporter uses the shared TraceConfig and its FI_HIDE_* environment settings. You can also pass a config explicitly:

from fi_instrumentation import TraceConfig

exporter = StrandsSpanExporter(
    HTTPSpanExporter(),
    capture_content=True,
    config=TraceConfig(hide_inputs=True, hide_error_details=True),
)

When content is disabled, native message events, tool payloads and error details are omitted. When content is enabled, input/output privacy settings apply to both native event-based and attribute-based messages. Because native messages are serialized blobs, a granular input or output hide flag omits that direction's entire content, including tool arguments/results, instead of retaining an unmasked copy. Native content events are projected into attributes, not exported a second time.

With hide_error_details=True, failed tool responses are also removed from later message history, even when the agent recovers. Tool responses whose success status is unavailable are omitted from history too; newer Strands semantic conventions discard that status. Successful tool spans still retain their own results when the native status confirms success.

If message history cannot be decoded as JSON, for example after truncation by OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, its content is omitted rather than exported as unchecked text. This also omits plain-text non-tool messages, including legacy callbacks, when their structure cannot be verified. Valid JSON text and successful direct tool results are preserved. This setting does not detect error text that your application or model copies into ordinary messages.

Span names, model/tool identifiers, session/user IDs and application resource attributes are metadata; do not put secrets in them. Unknown custom native attributes and link attributes are omitted. Other instrumentation scopes pass through unchanged: this adapter is not a privacy filter for the whole application. Content opt-in is not automatic credential detection.

Migrate existing setup

Keep traceai-strands installed. Replace the old register(...) plus configure_strands_tracing(...) setup with the exporter-wrapped register(...) above. Bare register() exports native spans but does not perform this adapter's semantic, aggregate-token or privacy conversion.

configure_strands_tracing, StrandsInstrumentor, create_traced_agent, attribute helpers and StrandsCallbackHandler remain available. Legacy setup now leaves metrics disabled by default and reuses an existing exporter when no OTLP endpoint is configured. If the provider already contains StrandsSpanExporter, legacy setup never adds a raw OTLP copy, even with ambient OTEL_* settings. The legacy setup helper does not retrofit the adapter onto exporters you already created. When using the adapter, add a separately wrapped console exporter rather than enable_console_exporter=True, which would bypass privacy filtering.

The optional callback handler is a legacy manual event API, not a replacement for native agent/model/tool tracing. Do not attach it to an Agent just to obtain those spans: Strands already emits them. Applications that explicitly call its on_agent_*, on_model_*, or on_tool_* methods can retain those calls; they create additional application spans and should not duplicate native operations. To stop exporting native traces, shut down the provider at application exit. uninstrument() only resets the legacy setup helper; it cannot remove Strands' own tracing or undo OpenTelemetry's global provider.

Known limitation: stopping a Python stream early

In strands-agents==1.63.0, stopping Agent.stream_async() after a content event and calling await stream.aclose() can leave the native model (chat) and event-loop (execute_event_loop_cycle) spans unfinished. Unfinished spans never reach an OpenTelemetry exporter, so the trace can be incomplete or lack model usage. This also occurs with plain Strands and an in-memory OpenTelemetry exporter, without traceAI. See the upstream early-close report and the related cancellation report.

For complete spans on successful calls, consume the async iterator until it is exhausted, rather than breaking on a content or result event. If appropriate for your application, stop displaying output but continue consuming the iterator to completion; this continues model/tool execution and may incur additional cost. Still close iterators when abandoning them for resource cleanup, but neither aclose() nor flushing the tracer provider repairs these unfinished native spans. There is no verified early-close or cancellation workaround here that guarantees complete spans. Do not rely on these traces for complete usage accounting when an invocation is interrupted.

Troubleshoot

  • No traces: install the global provider before creating the first Agent. Restart the process after changing a previously installed global provider; OpenTelemetry does not support replacing it.
  • Duplicate spans or usage: configure one wrapped exporter and remove additional raw OTLP exporters and lifecycle callbacks for native operations.
  • No prompts or responses: enable capture_content=True and check your FI_HIDE_* settings. Strands' own content-redaction settings can also remove content before it reaches the adapter.
  • Authentication errors: supply both FI_API_KEY and FI_SECRET_KEY, and check FI_BASE_URL for self-hosted deployments.

Resources

Metadata

Release files for traceai-strands 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceai-strands 0.1.2
File Size Uploaded Provenance Actions
traceai_strands-0.1.2.tar.gz 46.5 kB With provenance Details for traceai_strands-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceai-strands 0.1.2
File Interpreter ABI Platform Actions
traceai_strands-0.1.2-py3-none-any.whl Python 3 none any Details for traceai_strands-0.1.2-py3-none-any.whl

Total release size: 67.9 kB

Release files / traceai_strands-0.1.2.tar.gz

Download URL traceai_strands-0.1.2.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
060d13c69b56ea7717497ed2387c7355966158e144d5bf7b9ed2d478183dbc77
BLAKE2b-256 checksum
How to use checksums
04d58512fdb02318ce362a50517d7bb5b7b7f79d96d0224ac38b9bad93f8d3a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / traceai_strands-0.1.2-py3-none-any.whl

Download URL traceai_strands-0.1.2-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a6bdd55151ce4b02fb7e13cee33357e90e47b9704333d5c3b9308ec4626e298
BLAKE2b-256 checksum
How to use checksums
d79b23d8a15d2762f2cb061ab1d786df52eaf8e4459bc629e9450ac4195e2783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for traceai-strands 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for traceai_strands-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page