@@ -9,28 +9,54 @@ import kotlinx.serialization.json.JsonElement
99import kotlinx.serialization.json.JsonObject
1010
1111/* *
12- * Represents the context for handling tool-specific events within the framework .
12+ * Represents the context for handling tool call events .
1313 */
14- public interface ToolCallEventContext : AgentLifecycleEventContext
14+ public interface ToolCallEventContext : AgentLifecycleEventContext {
15+ /* *
16+ * [runId] The unique identifier for this tool call session;
17+ */
18+ public val runId: String
19+
20+ /* *
21+ * [toolCallId] The unique identifier for this tool call;
22+ */
23+ public val toolCallId: String?
24+
25+ /* *
26+ * [toolName] The tool name that is being executed;
27+ */
28+ public val toolName: String
29+
30+ /* *
31+ * [toolDescription] A description of the tool being executed;
32+ */
33+ public val toolDescription: String?
34+
35+ /* *
36+ * [toolArgs] The arguments provided for the tool execution, adhering to the tool's expected input structure.
37+ */
38+ public val toolArgs: JsonObject
39+
40+ /* *
41+ * [context] The agent context associated with the tool call;
42+ */
43+ public val context: AIAgentContext
44+ }
1545
1646/* *
1747 * Represents the context for handling a tool call event.
1848 *
1949 * @property executionInfo The execution information containing parentId and current execution path;
20- * @property runId The unique identifier for this tool call session;
21- * @property toolCallId The unique identifier for this tool call;
22- * @property toolName The tool name that is being executed;
23- * @property toolArgs The arguments provided for the tool execution, adhering to the tool's expected input structure.
2450 */
2551public data class ToolCallStartingContext (
2652 override val eventId : String ,
2753 override val executionInfo : AgentExecutionInfo ,
28- val runId : String ,
29- val toolCallId : String? ,
30- val toolName : String ,
31- val toolDescription : String? ,
32- val toolArgs : JsonObject ,
33- val context : AIAgentContext
54+ override val runId : String ,
55+ override val toolCallId : String? ,
56+ override val toolName : String ,
57+ override val toolDescription : String? ,
58+ override val toolArgs : JsonObject ,
59+ override val context : AIAgentContext
3460) : ToolCallEventContext {
3561 override val eventType: AgentLifecycleEventType = AgentLifecycleEventType .ToolCallStarting
3662}
@@ -39,25 +65,20 @@ public data class ToolCallStartingContext(
3965 * Represents the context for handling validation errors that occur during the execution of a tool.
4066 *
4167 * @property executionInfo The execution information containing parentId and current execution path;
42- * @property runId The unique identifier for this tool call session;
43- * @property toolCallId The unique identifier for this tool call;
44- * @property toolName The name of the tool associated with the validation error;
45- * @property toolDescription A description of the tool being executed;
46- * @property toolArgs The arguments passed to the tool when the error occurred;
4768 * @property message A message describing the validation error.
4869 * @property error The [AIAgentError] error describing the validation issue.
4970 */
5071public data class ToolValidationFailedContext (
5172 override val eventId : String ,
5273 override val executionInfo : AgentExecutionInfo ,
53- val runId : String ,
54- val toolCallId : String? ,
55- val toolName : String ,
56- val toolDescription : String? ,
57- val toolArgs : JsonObject ,
74+ override val runId : String ,
75+ override val toolCallId : String? ,
76+ override val toolName : String ,
77+ override val toolDescription : String? ,
78+ override val toolArgs : JsonObject ,
5879 val message : String ,
5980 val error : AIAgentError ,
60- val context : AIAgentContext
81+ override val context : AIAgentContext
6182) : ToolCallEventContext {
6283 override val eventType: AgentLifecycleEventType = AgentLifecycleEventType .ToolValidationFailed
6384}
@@ -66,25 +87,20 @@ public data class ToolValidationFailedContext(
6687 * Represents the context provided to handle a failure during the execution of a tool.
6788 *
6889 * @property executionInfo The execution information containing parentId and current execution path;
69- * @property runId The unique identifier for this tool call session;
70- * @property toolCallId The unique identifier for this tool call;
71- * @property toolName The name of the tool being executed when the failure occurred;
72- * @property toolDescription A description of the tool being executed;
73- * @property toolArgs The arguments that were passed to the tool during execution;
7490 * @property message A message describing the failure that occurred.
7591 * @property error The [AIAgentError] instance describing the tool call failure.
7692 */
7793public data class ToolCallFailedContext (
7894 override val eventId : String ,
7995 override val executionInfo : AgentExecutionInfo ,
80- val runId : String ,
81- val toolCallId : String? ,
82- val toolName : String ,
83- val toolDescription : String? ,
84- val toolArgs : JsonObject ,
96+ override val runId : String ,
97+ override val toolCallId : String? ,
98+ override val toolName : String ,
99+ override val toolDescription : String? ,
100+ override val toolArgs : JsonObject ,
85101 val message : String ,
86102 val error : AIAgentError ? ,
87- val context : AIAgentContext
103+ override val context : AIAgentContext
88104) : ToolCallEventContext {
89105 override val eventType: AgentLifecycleEventType = AgentLifecycleEventType .ToolCallFailed
90106}
@@ -93,23 +109,18 @@ public data class ToolCallFailedContext(
93109 * Represents the context used when handling the result of a tool call.
94110 *
95111 * @property executionInfo The execution information containing parentId and current execution path;
96- * @property runId The unique identifier for this tool call session;
97- * @property toolCallId The unique identifier for this tool call;
98- * @property toolName The name of the tool being executed;
99- * @property toolDescription A description of the tool being executed;
100- * @property toolArgs The arguments required by the tool for execution;
101112 * @property toolResult An optional result produced by the tool after execution can be null if not applicable.
102113 */
103114public data class ToolCallCompletedContext (
104115 override val eventId : String ,
105116 override val executionInfo : AgentExecutionInfo ,
106- val runId : String ,
107- val toolCallId : String? ,
108- val toolName : String ,
109- val toolDescription : String? ,
110- val toolArgs : JsonObject ,
117+ override val runId : String ,
118+ override val toolCallId : String? ,
119+ override val toolName : String ,
120+ override val toolDescription : String? ,
121+ override val toolArgs : JsonObject ,
111122 val toolResult : JsonElement ? ,
112- val context : AIAgentContext
123+ override val context : AIAgentContext
113124) : ToolCallEventContext {
114125 override val eventType: AgentLifecycleEventType = AgentLifecycleEventType .ToolCallCompleted
115126}
0 commit comments