Strands Agents
Strands Agents (the strands-agents package, by AWS) has native OpenTelemetry
tracing. It emits spans through the OTel global tracer provider, so once
logfire.configure() has set Logfire as the global provider, Strands traces flow to
Logfire automatically — no extra exporter needed.
pip install logfire strands-agents strands-agents-tools
Set Strands’ semantic-convention options in your terminal before starting the application. The first option selects the latest generative AI attributes; the second records messages as attributes on their spans instead of separate span events:
export OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental,gen_ai_span_attributes_only
Then call logfire.configure() before you construct your Agent:
from strands import Agent, tool
import logfire
# Logfire registers itself as the global OTel tracer provider.
logfire.configure()
@tool
def weather(city: str) -> str:
"""Get the current weather for a city."""
return f"It's sunny in {city}."
agent = Agent(
tools=[weather],
# trace_attributes are attached to every span this agent produces.
trace_attributes={'session.id': 'demo-1', 'user.id': 'you@example.com'},
)
result = agent("What's the weather in Lisbon?")
print(result)
You’ll see a trace in Logfire with the agent invocation, the model (LLM) call, and the weather tool call
as a nested timeline. The model and agent spans contain standard gen_ai.input.messages and
gen_ai.output.messages attributes for the conversation. Strands runs also appear in the specialized Agents
view; the support matrix shows which columns each view populates.
Keep your agents’ system prompts in Prompt Management and fetch them at runtime:
pip install 'logfire[variables]'
from strands import Agent
from pydantic import BaseModel
import logfire
logfire.configure()
class SystemInputs(BaseModel):
role: str
system_var = logfire.template_var(
name='prompt__strands_system',
type=str,
default='You are a helpful assistant.',
inputs_type=SystemInputs,
)
with system_var.get(SystemInputs(role='a travel assistant'), label='production') as resolved:
system_prompt = resolved.value
agent = Agent(system_prompt=system_prompt)
See Use Prompts in Your Application for the full workflow.