33This module defines the events that are emitted as Agents run through the lifecycle of a request.
44"""
55
6- from dataclasses import dataclass
6+ from dataclasses import dataclass , field
77from typing import Any , Optional
88
99from ...hooks import HookEvent
@@ -29,8 +29,8 @@ class BeforeToolInvocationEvent(HookEvent):
2929 """
3030
3131 selected_tool : Optional [AgentTool ] = None
32- tool_use : Optional [ ToolUse ] = None
33- invocation_state : dict [str , Any ] = None
32+ tool_use : ToolUse
33+ invocation_state : dict [str , Any ]
3434
3535 def _can_write (self , name : str ) -> bool :
3636 return name in ["selected_tool" , "tool_use" ]
@@ -55,10 +55,10 @@ class AfterToolInvocationEvent(HookEvent):
5555 or an Exception if the tool execution failed.
5656 """
5757
58- selected_tool : Optional [AgentTool ] = None
59- tool_use : Optional [ ToolUse ] = None
60- invocation_state : dict [str , Any ] = None
61- result : Optional [ ToolResult ] = None
58+ selected_tool : Optional [AgentTool ]= None
59+ tool_use : ToolUse
60+ invocation_state : dict [str , Any ]
61+ result : ToolResult
6262 exception : Optional [Exception ] = None
6363
6464 def _can_write (self , name : str ) -> bool :
0 commit comments