respan-instrumentation-strands-agents
Respan instrumentation plugin for Strands Agents.
This package consumes Strands Agents' native OpenTelemetry spans and maps them directly into the Respan span contract used by the OTLP pipeline. It does not require OpenInference at runtime.
Install
pip install respan-instrumentation-strands-agents
Strands Agents 1.20.0 or newer is required because that release includes the
native tools_config telemetry surface used for canonical chat tool schemas.
Quickstart
import os
from respan import Respan
from respan_instrumentation_strands_agents import StrandsAgentsInstrumentor
from strands import Agent, tool
from strands.models.openai import OpenAIModel
respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
respan = Respan(
api_key=respan_api_key,
base_url=respan_base_url,
instrumentations=[StrandsAgentsInstrumentor()],
)
model = OpenAIModel(
model_id="gpt-4o-mini",
client_args={"api_key": respan_api_key, "base_url": respan_base_url},
)
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"The weather in {city} is sunny and 72F."
agent = Agent(
name="WeatherAgent",
model=model,
tools=[get_weather],
system_prompt="You are a concise weather assistant.",
)
try:
result = agent("What is the weather in Seattle?")
print(result)
finally:
respan.flush()
respan.shutdown()
Notes
- Initialize
Respan(...)before running the agent so Strands uses the active Respan OpenTelemetry provider. - The instrumentor can refresh an already-created Strands tracer singleton when possible, which helps when an agent was constructed before activation.
- Tool definitions are enabled by default via Strands'
gen_ai_tool_definitionssemantic-convention opt-in. They are moved from the common-only agent span to canonicalllm.request.functionson each model/chat span. - Agent spans remain common-only by contract; model, provider, and usage fields belong to the child chat spans.
Metadata
Release files for respan-instrumentation-strands-agents 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| respan_instrumentation_strands_agents-0.1.1.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| respan_instrumentation_strands_agents-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.4 kB
Release files / respan_instrumentation_strands_agents-0.1.1.tar.gz
| Download URL | respan_instrumentation_strands_agents-0.1.1.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85a8600b4220b8079bb2418e1fa3f150654d92cbc0f9cd3974e5693a4987318f
|
|
BLAKE2b-256 checksum How to use checksums |
559ec1deb57eccdba4a85404c46ee3f16e21e0d8396ef3c90016a305acf6c71b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / respan_instrumentation_strands_agents-0.1.1-py3-none-any.whl
| Download URL | respan_instrumentation_strands_agents-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d733336839124b9d681362f2dbd22cf4e35f8c26f6c894edf84f2ab56c9eb692
|
|
BLAKE2b-256 checksum How to use checksums |
4a9ea6e00fc7a41382135790f3bab5f324868f05aa26ad70b51f59db53cb7ec8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|