strands.handlers.callback_handler
This module provides handlers for formatting and displaying events from the agent.
PrintingCallbackHandler
Section titled “PrintingCallbackHandler”class PrintingCallbackHandler()Defined in: src/strands/handlers/callback_handler.py:7
Handler for streaming text output and tool invocations to stdout.
__init__
Section titled “__init__”def __init__(verbose_tool_use: bool = True) -> NoneDefined in: src/strands/handlers/callback_handler.py:10
Initialize handler.
Arguments:
verbose_tool_use- Print out verbose information about tool calls.
__call__
Section titled “__call__”def __call__(**kwargs: Any) -> NoneDefined in: src/strands/handlers/callback_handler.py:19
Stream text output and tool invocations to stdout.
Arguments:
**kwargs- Callback event data including:- reasoningText (Optional[str]): Reasoning text to print if provided.
- data (str): Text content to stream.
- complete (bool): Whether this is the final chunk of a response.
- event (dict): ModelStreamChunkEvent.
CompositeCallbackHandler
Section titled “CompositeCallbackHandler”class CompositeCallbackHandler()Defined in: src/strands/handlers/callback_handler.py:50
Class-based callback handler that combines multiple callback handlers.
This handler allows multiple callback handlers to be invoked for the same events, enabling different processing or output formats for the same stream data.
__init__
Section titled “__init__”def __init__(*handlers: Callable) -> NoneDefined in: src/strands/handlers/callback_handler.py:57
Initialize handler.
__call__
Section titled “__call__”def __call__(**kwargs: Any) -> NoneDefined in: src/strands/handlers/callback_handler.py:61
Invoke all handlers in the chain.
null_callback_handler
Section titled “null_callback_handler”def null_callback_handler(**_kwargs: Any) -> NoneDefined in: src/strands/handlers/callback_handler.py:67
Callback handler that discards all output.
Arguments:
**_kwargs- Event data (ignored).