Handler.defaultDefault handler that does nothing for all events.
This is the recommended base class for most use cases. Override only the methods you need:
let handler =
object
inherit Claude.Handler.default
method! on_text t =
Printf.printf "Text: %s\n" (Response.Text.content t)
endMethods you don't override will simply be ignored, making this ideal for prototyping and for cases where you only care about specific events.
on_text t is called when text content is received from the assistant.
on_tool_use t is called when the assistant requests a tool invocation. The caller is responsible for responding with Client.respond_to_tool.
on_tool_result t is called when a tool result is observed in the message stream. This is typically an echo of what was sent to Claude.
on_thinking t is called when internal reasoning content is received.
on_init t is called when the session is initialized. This provides session metadata like session_id and model.
on_error t is called when an error occurs. Errors can come from the system (e.g., CLI errors) or from the assistant (e.g., rate limits).