Metadata-Version: 2.4
Name: respan-instrumentation-strands-agents
Version: 0.1.0
Summary: Respan instrumentation plugin for Strands Agents
License: Apache 2.0
Author: Respan
Author-email: team@respan.ai
Requires-Python: >=3.11,<3.14
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: opentelemetry-semantic-conventions-ai (>=0.5.1)
Requires-Dist: respan-sdk (>=2.6.1)
Requires-Dist: respan-tracing (>=2.17.0)
Requires-Dist: strands-agents[openai] (>=1.0.0,<2.0.0)
Description-Content-Type: text/markdown

# respan-instrumentation-strands-agents

Respan instrumentation plugin for [Strands Agents](https://strandsagents.com/).

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

```bash
pip install respan-instrumentation-strands-agents
```

## Quickstart

```python
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.",
)

result = agent("What is the weather in Seattle?")
print(result)

respan.flush()
```

## 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_definitions`
  semantic-convention opt-in and are exported as canonical `llm.request.functions`
  attributes.

