Skip to content

strands.handlers.callback_handler

This module provides handlers for formatting and displaying events from the agent.

PrintingCallbackHandler

class PrintingCallbackHandler()

Defined in: src/strands/handlers/callback_handler.py:7

Handler for streaming text output and tool invocations to stdout.

__init__

def __init__(verbose_tool_use: bool = True) -> None

Defined in: src/strands/handlers/callback_handler.py:10

Initialize handler.

Arguments:

  • verbose_tool_use - Print out verbose information about tool calls.

__call__

def __call__(**kwargs: Any) -> None

Defined 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

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__

def __init__(*handlers: Callable) -> None

Defined in: src/strands/handlers/callback_handler.py:57

Initialize handler.

__call__

def __call__(**kwargs: Any) -> None

Defined in: src/strands/handlers/callback_handler.py:61

Invoke all handlers in the chain.

null_callback_handler

def null_callback_handler(**_kwargs: Any) -> None

Defined in: src/strands/handlers/callback_handler.py:67

Callback handler that discards all output.

Arguments:

  • **_kwargs - Event data (ignored).