Strands Integration

Full observability for Strands agents. Capture tool execution, model interactions, and agent reasoning with automatic instrumentation.

Strands >= 0.1.0AgentsToolsModel Interactions

Installation

Terminal
pip install turingpulse_sdk turingpulse_sdk_strands strands-agents

Quick Start

1. Initialize & Instrument

setup.py
from turingpulse_sdk import init, TuringPulseConfig
from turingpulse_sdk_strands import instrument_strands

# Initialize TuringPulse
init(TuringPulseConfig(
    api_key="sk_live_your_api_key",
    workflow_name="my-project",
))

# Enable auto-instrumentation for Strands
instrument_strands()

2. Use Strands Normally

main.py
from strands import Agent
from strands.tools import tool

@tool
def get_stock_price(symbol: str) -> dict:
    """Get the current stock price for a given symbol."""
    return {"symbol": symbol, "price": 185.50, "currency": "USD"}

agent = Agent(
    model="us.anthropic.claude-sonnet-4-20250514",
    tools=[get_stock_price],
    system_prompt="You are a financial assistant.",
)

# Run the agent - traces are captured automatically
response = agent("What's the current price of AAPL?")
print(response)
ℹ️
Zero Code Changes
Once auto-instrumentation is enabled, all Strands agent runs, tool invocations, and model calls are automatically traced.

What Gets Captured

Data PointDescriptionExample
Agent RunsFull trace for each agent invocationagent("What's the price of AAPL?")
Tool ExecutionTool calls with inputs, outputs, and durationget_stock_price(symbol='AAPL')
Model InteractionsModel name, parameters, and response metadataclaude-sonnet-4-20250514, temp=0.7
Agent ReasoningInternal reasoning steps and decision pointsstep: select_tool, tool: get_stock_price
Token UsageInput and output token counts per callprompt: 180, completion: 95
LatencyEnd-to-end and per-step timingtotal: 2100ms, tool: 150ms
ErrorsExceptions with full context and stack tracesToolError: API rate limit exceeded

Advanced Configuration

config.py
from turingpulse_sdk import KPIConfig
from turingpulse_sdk_strands import instrument_strands

run = instrument_strands(
    agent,
    name="strands-service",
    model="anthropic.claude-3-sonnet",
    provider="bedrock",
    kpis=[
        KPIConfig(kpi_id="latency_ms", use_duration=True, alert_threshold=10000),
        KPIConfig(kpi_id="tokens", alert_threshold=5000, comparator="gt"),
    ],
)

Multi-Tool Agents

multi-tool.py
from strands import Agent
from strands.tools import tool

@tool
def search_web(query: str) -> str:
    """Search the web for information."""
    return f"Results for: {query}"

@tool
def calculate(expression: str) -> float:
    """Evaluate a mathematical expression."""
    return eval(expression)

@tool
def write_file(filename: str, content: str) -> str:
    """Write content to a file."""
    return f"Written to {filename}"

agent = Agent(
    model="us.anthropic.claude-sonnet-4-20250514",
    tools=[search_web, calculate, write_file],
    system_prompt="You are a research assistant.",
)

# All tool calls are captured with their execution order and dependencies
response = agent("Research the GDP of Japan and calculate the per-capita value")
💡
Tool Execution Tracking
TuringPulse captures the full tool execution chain, including the order of tool calls and their dependencies within a single agent run.

Next Steps