> ## Documentation Index
> Fetch the complete documentation index at: https://askmarvin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# handlers

# `marvin.handlers.handlers`

## Classes

### `AsyncHandler`

```python theme={null}
class AsyncHandler()
```

**Methods:**

* **`on_actor_end_turn`**
  ```python theme={null}
  def on_actor_end_turn(self, event: ActorEndTurnEvent)
  ```
  Handles actor turn completion. Called when an actor finishes its processing turn.
* **`on_actor_message`**
  ```python theme={null}
  def on_actor_message(self, event: ActorMessageEvent)
  ```
  Handles complete messages from actors. Called when an actor produces a full response.
  This is the final event that follows any related actor\_message\_delta events.
* **`on_actor_message_delta`**
  ```python theme={null}
  def on_actor_message_delta(self, event: ActorMessageDeltaEvent)
  ```
  Handles streaming updates to actor messages. Called multiple times during message generation.
  These delta events always precede the final actor\_message event.
* **`on_actor_start_turn`**
  ```python theme={null}
  def on_actor_start_turn(self, event: ActorStartTurnEvent)
  ```
  Handles actor turn initiation. Called when an actor begins its processing turn.
* **`on_end_turn_tool_call`**
  ```python theme={null}
  def on_end_turn_tool_call(self, event: EndTurnToolCallEvent)
  ```
  Handles special end-of-turn tool calls. Called when actors use tools to signal turn completion.
  This event is produced instantly when an end turn tool is recognized (based on tool name).
  It follows any tool\_call\_delta events and precedes end\_turn\_tool\_result or tool\_retry events.
* **`on_end_turn_tool_result`**
  ```python theme={null}
  def on_end_turn_tool_result(self, event: EndTurnToolResultEvent)
  ```
  Handles the final result from an end turn tool.
  This is the final event in the end turn tool sequence, following end\_turn\_tool\_call and any tool\_retry events.
* **`on_event`**
  ```python theme={null}
  def on_event(self, event: Event)
  ```
  Called for every event before specific handlers. Override for global event processing.
* **`on_orchestrator_end`**
  ```python theme={null}
  def on_orchestrator_end(self, event: OrchestratorEndEvent)
  ```
  Handles normal orchestrator completion. Called when orchestration ends (including after an error).
* **`on_orchestrator_error`**
  ```python theme={null}
  def on_orchestrator_error(self, event: OrchestratorErrorEvent)
  ```
  Handles orchestrator exceptions. Called when an error occurs during orchestration.
* **`on_orchestrator_start`**
  ```python theme={null}
  def on_orchestrator_start(self, event: OrchestratorStartEvent)
  ```
  Handles orchestrator initialization. Called once when orchestration begins.
* **`on_tool_call`**
  ```python theme={null}
  def on_tool_call(self, event: ToolCallEvent)
  ```
  Handles tool call events. Called when an actor invokes a function tool.
  This follows any tool\_call\_delta events and precedes tool\_retry or tool\_result events.
* **`on_tool_call_delta`**
  ```python theme={null}
  def on_tool_call_delta(self, event: ToolCallDeltaEvent)
  ```
  Handles streaming updates during tool call formation. Called multiple times as tool calls are generated.
  These delta events always precede either a tool\_call event (for function tools) or an end\_turn\_tool\_call event.
* **`on_tool_result`**
  ```python theme={null}
  def on_tool_result(self, event: ToolResultEvent)
  ```
  Handles successful tool execution results. Called when a function tool returns output.
  This is the final event in the function tool sequence, following tool\_call and any tool\_retry events.
* **`on_tool_retry`**
  ```python theme={null}
  def on_tool_retry(self, event: ToolRetryEvent)
  ```
  Handles tool retry events. Called when a tool execution fails and needs to be retried.
  Can occur for both function tools and end turn tools before their respective final result events.
* **`on_user_message`**
  ```python theme={null}
  def on_user_message(self, event: UserMessageEvent)
  ```
  Handles messages from the user. Called when a user sends input to the system.

### `Handler`

```python theme={null}
class Handler()
```

**Methods:**

* **`on_actor_end_turn`**
  ```python theme={null}
  def on_actor_end_turn(self, event: ActorEndTurnEvent)
  ```
  Handles actor turn completion. Called when an actor finishes its processing turn.
* **`on_actor_message`**
  ```python theme={null}
  def on_actor_message(self, event: ActorMessageEvent)
  ```
  Handles complete messages from actors. Called when an actor produces a full response.
  This is the final event that follows any related actor\_message\_delta events.
* **`on_actor_message_delta`**
  ```python theme={null}
  def on_actor_message_delta(self, event: ActorMessageDeltaEvent)
  ```
  Handles streaming updates to actor messages. Called multiple times during message generation.
  These delta events always precede the final actor\_message event.
* **`on_actor_start_turn`**
  ```python theme={null}
  def on_actor_start_turn(self, event: ActorStartTurnEvent)
  ```
  Handles actor turn initiation. Called when an actor begins its processing turn.
* **`on_end_turn_tool_call`**
  ```python theme={null}
  def on_end_turn_tool_call(self, event: EndTurnToolCallEvent)
  ```
  Handles special end-of-turn tool calls. Called when actors use tools to signal turn completion.
  This event is produced instantly when an end turn tool is recognized (based on tool name).
  It follows any tool\_call\_delta events and precedes end\_turn\_tool\_result or tool\_retry events.
* **`on_end_turn_tool_result`**
  ```python theme={null}
  def on_end_turn_tool_result(self, event: EndTurnToolResultEvent)
  ```
  Handles the final result from an end turn tool.
  This is the final event in the end turn tool sequence, following end\_turn\_tool\_call and any tool\_retry events.
* **`on_event`**
  ```python theme={null}
  def on_event(self, event: Event)
  ```
  Called for every event before specific handlers. Override for global event processing.
* **`on_orchestrator_end`**
  ```python theme={null}
  def on_orchestrator_end(self, event: OrchestratorEndEvent)
  ```
  Handles normal orchestrator completion. Called when orchestration ends (including after an error).
* **`on_orchestrator_error`**
  ```python theme={null}
  def on_orchestrator_error(self, event: OrchestratorErrorEvent)
  ```
  Handles orchestrator exceptions. Called when an error occurs during orchestration.
* **`on_orchestrator_start`**
  ```python theme={null}
  def on_orchestrator_start(self, event: OrchestratorStartEvent)
  ```
  Handles orchestrator initialization. Called once when orchestration begins.
* **`on_tool_call`**
  ```python theme={null}
  def on_tool_call(self, event: ToolCallEvent)
  ```
  Handles tool call events. Called when an actor invokes a function tool.
  This follows any tool\_call\_delta events and precedes tool\_retry or tool\_result events.
* **`on_tool_call_delta`**
  ```python theme={null}
  def on_tool_call_delta(self, event: ToolCallDeltaEvent)
  ```
  Handles streaming updates during tool call formation. Called multiple times as tool calls are generated.
  These delta events always precede either a tool\_call event (for function tools) or an end\_turn\_tool\_call event.
* **`on_tool_result`**
  ```python theme={null}
  def on_tool_result(self, event: ToolResultEvent)
  ```
  Handles successful tool execution results. Called when a function tool returns output.
  This is the final event in the function tool sequence, following tool\_call and any tool\_retry events.
* **`on_tool_retry`**
  ```python theme={null}
  def on_tool_retry(self, event: ToolRetryEvent)
  ```
  Handles tool retry events. Called when a tool execution fails and needs to be retried.
  Can occur for both function tools and end turn tools before their respective final result events.
* **`on_user_message`**
  ```python theme={null}
  def on_user_message(self, event: UserMessageEvent)
  ```
  Handles messages from the user. Called when a user sends input to the system.

***

**Parent Module:** [`handlers`](marvin-handlers)
