Skip to main content
Centralized instrumentation hook for Strands agents with Fiddler integration. This hook provider automatically captures telemetry data from Strands agents and enriches OpenTelemetry spans with Fiddler-specific attributes. It handles three key events: before invocation, after tool execution, and after model calls. The hook is automatically injected when using StrandsAgentInstrumentor, so users typically don’t need to manually add it to their agents.

Example

from strands import Agent
from fiddler_strandsagents import FiddlerInstrumentationHook

# Manual usage (not needed with StrandsAgentInstrumentor)
agent = Agent(
    model=model,
    system_prompt="...",
    hooks=[FiddlerInstrumentationHook()]
)

register_hooks()

Register hook callbacks with the Strands agent registry. This method is called by the Strands framework to register callbacks for various agent lifecycle events.

Parameters

registry
HookRegistry
required
The HookRegistry to register callbacks with

tool_end()

Handle the completion of a tool invocation. Enriches the current OpenTelemetry span with:
  • Custom attributes set via set_span_attributes() (prefixed ‘fiddler.span.user.’)
  • gen_ai.tool.input — JSON-serialised input arguments passed to the tool
  • gen_ai.tool.output — Text extracted from the tool result content

Parameters

event
AfterToolCallEvent
required
AfterToolCallEvent (or legacy AfterToolInvocationEvent) containing tool execution details

model_end()

Handle the completion of a model invocation. Enriches the current OpenTelemetry span with:
  • gen_ai.llm.context — retrieved context set via set_llm_context()
  • Custom attributes set via set_span_attributes() (prefixed ‘fiddler.span.user.’)
  • gen_ai.llm.output — text extracted from the model’s response message

Parameters

event
AfterModelCallEvent
required
AfterModelCallEvent (or legacy AfterModelInvocationEvent) containing model execution details

before_invocation()

Handle the start of an agent invocation. Enriches the current OpenTelemetry span with:
  • Conversation ID set via set_conversation_id()
  • Session attributes set via set_session_attributes()
  • gen_ai.llm.input.user — text of the last user message in the invocation
Session attributes and conversation ID are also written to event.agent.trace_attributes so that Strands (>=1.19.0) propagates them natively to all child spans (model invoke, tool call, event-loop cycle, etc.) without needing manual parent-to-child denormalisation in a SpanProcessor.

Parameters

event
BeforeInvocationEvent
required
BeforeInvocationEvent containing agent invocation details