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-agentsQuick 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 Point | Description | Example |
|---|---|---|
| Agent Runs | Full trace for each agent invocation | agent("What's the price of AAPL?") |
| Tool Execution | Tool calls with inputs, outputs, and duration | get_stock_price(symbol='AAPL') |
| Model Interactions | Model name, parameters, and response metadata | claude-sonnet-4-20250514, temp=0.7 |
| Agent Reasoning | Internal reasoning steps and decision points | step: select_tool, tool: get_stock_price |
| Token Usage | Input and output token counts per call | prompt: 180, completion: 95 |
| Latency | End-to-end and per-step timing | total: 2100ms, tool: 150ms |
| Errors | Exceptions with full context and stack traces | ToolError: 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.