Example
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
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-serialized input arguments passed to the tool
- gen_ai.tool.output — Text extracted from the tool result content
Parameters
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
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
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 denormalization in
a SpanProcessor.