@@ -14,6 +14,7 @@ class EventType(str, Enum):
14
14
"""
15
15
The type of event.
16
16
"""
17
+
17
18
TEXT_MESSAGE_START = "TEXT_MESSAGE_START"
18
19
TEXT_MESSAGE_CONTENT = "TEXT_MESSAGE_CONTENT"
19
20
TEXT_MESSAGE_END = "TEXT_MESSAGE_END"
@@ -44,6 +45,7 @@ class BaseEvent(ConfiguredBaseModel):
44
45
"""
45
46
Base event for all events in the Agent User Interaction Protocol.
46
47
"""
48
+
47
49
type : EventType
48
50
timestamp : Optional [int ] = None
49
51
raw_event : Optional [JSONValue ] = None
@@ -53,6 +55,7 @@ class TextMessageStartEvent(BaseEvent):
53
55
"""
54
56
Event indicating the start of a text message.
55
57
"""
58
+
56
59
type : Literal [EventType .TEXT_MESSAGE_START ] = EventType .TEXT_MESSAGE_START # pyright: ignore[reportIncompatibleVariableOverride]
57
60
message_id : str
58
61
role : Literal ["assistant" ] = "assistant"
@@ -62,6 +65,7 @@ class TextMessageContentEvent(BaseEvent):
62
65
"""
63
66
Event containing a piece of text message content.
64
67
"""
68
+
65
69
type : Literal [EventType .TEXT_MESSAGE_CONTENT ] = EventType .TEXT_MESSAGE_CONTENT # pyright: ignore[reportIncompatibleVariableOverride]
66
70
message_id : str
67
71
delta : str = Field (min_length = 1 )
@@ -71,41 +75,58 @@ class TextMessageEndEvent(BaseEvent):
71
75
"""
72
76
Event indicating the end of a text message.
73
77
"""
78
+
74
79
type : Literal [EventType .TEXT_MESSAGE_END ] = EventType .TEXT_MESSAGE_END # pyright: ignore[reportIncompatibleVariableOverride]
75
80
message_id : str
76
81
82
+
77
83
class TextMessageChunkEvent (BaseEvent ):
78
84
"""
79
85
Event containing a chunk of text message content.
80
86
"""
87
+
81
88
type : Literal [EventType .TEXT_MESSAGE_CHUNK ] = EventType .TEXT_MESSAGE_CHUNK # pyright: ignore[reportIncompatibleVariableOverride]
82
89
message_id : Optional [str ] = None
83
90
role : Optional [Literal ["assistant" ]] = None
84
91
delta : Optional [str ] = None
85
92
93
+
86
94
class ThinkingTextMessageStartEvent (BaseEvent ):
87
95
"""
88
96
Event indicating the start of a thinking text message.
89
97
"""
90
- type : Literal [EventType .THINKING_TEXT_MESSAGE_START ] = EventType .THINKING_TEXT_MESSAGE_START # pyright: ignore[reportIncompatibleVariableOverride]
98
+
99
+ type : Literal [EventType .THINKING_TEXT_MESSAGE_START ] = (
100
+ EventType .THINKING_TEXT_MESSAGE_START
101
+ ) # pyright: ignore[reportIncompatibleVariableOverride]
102
+
91
103
92
104
class ThinkingTextMessageContentEvent (BaseEvent ):
93
105
"""
94
106
Event indicating a piece of a thinking text message.
95
107
"""
96
- type : Literal [EventType .THINKING_TEXT_MESSAGE_CONTENT ] = EventType .THINKING_TEXT_MESSAGE_CONTENT # pyright: ignore[reportIncompatibleVariableOverride]
108
+
109
+ type : Literal [EventType .THINKING_TEXT_MESSAGE_CONTENT ] = (
110
+ EventType .THINKING_TEXT_MESSAGE_CONTENT
111
+ ) # pyright: ignore[reportIncompatibleVariableOverride]
97
112
delta : str = Field (min_length = 1 )
98
113
114
+
99
115
class ThinkingTextMessageEndEvent (BaseEvent ):
100
116
"""
101
117
Event indicating the end of a thinking text message.
102
118
"""
103
- type : Literal [EventType .THINKING_TEXT_MESSAGE_END ] = EventType .THINKING_TEXT_MESSAGE_END # pyright: ignore[reportIncompatibleVariableOverride]
119
+
120
+ type : Literal [EventType .THINKING_TEXT_MESSAGE_END ] = (
121
+ EventType .THINKING_TEXT_MESSAGE_END
122
+ ) # pyright: ignore[reportIncompatibleVariableOverride]
123
+
104
124
105
125
class ToolCallStartEvent (BaseEvent ):
106
126
"""
107
127
Event indicating the start of a tool call.
108
128
"""
129
+
109
130
type : Literal [EventType .TOOL_CALL_START ] = EventType .TOOL_CALL_START # pyright: ignore[reportIncompatibleVariableOverride]
110
131
tool_call_id : str
111
132
tool_call_name : str
@@ -116,6 +137,7 @@ class ToolCallArgsEvent(BaseEvent):
116
137
"""
117
138
Event containing tool call arguments.
118
139
"""
140
+
119
141
type : Literal [EventType .TOOL_CALL_ARGS ] = EventType .TOOL_CALL_ARGS # pyright: ignore[reportIncompatibleVariableOverride]
120
142
tool_call_id : str
121
143
delta : str
@@ -125,46 +147,57 @@ class ToolCallEndEvent(BaseEvent):
125
147
"""
126
148
Event indicating the end of a tool call.
127
149
"""
150
+
128
151
type : Literal [EventType .TOOL_CALL_END ] = EventType .TOOL_CALL_END # pyright: ignore[reportIncompatibleVariableOverride]
129
152
tool_call_id : str
130
153
154
+
131
155
class ToolCallChunkEvent (BaseEvent ):
132
156
"""
133
157
Event containing a chunk of tool call content.
134
158
"""
159
+
135
160
type : Literal [EventType .TOOL_CALL_CHUNK ] = EventType .TOOL_CALL_CHUNK # pyright: ignore[reportIncompatibleVariableOverride]
136
161
tool_call_id : Optional [str ] = None
137
162
tool_call_name : Optional [str ] = None
138
163
parent_message_id : Optional [str ] = None
139
164
delta : Optional [str ] = None
140
165
166
+
141
167
class ToolCallResultEvent (BaseEvent ):
142
168
"""
143
169
Event containing the result of a tool call.
144
170
"""
171
+
145
172
message_id : str
146
173
type : Literal [EventType .TOOL_CALL_RESULT ] = EventType .TOOL_CALL_RESULT # pyright: ignore[reportIncompatibleVariableOverride]
147
174
tool_call_id : str
148
175
content : str
149
176
role : Optional [Literal ["tool" ]] = None
150
177
178
+
151
179
class ThinkingStartEvent (BaseEvent ):
152
180
"""
153
181
Event indicating the start of a thinking step event.
154
182
"""
183
+
155
184
type : Literal [EventType .THINKING_START ] = EventType .THINKING_START # pyright: ignore[reportIncompatibleVariableOverride]
156
185
title : Optional [str ] = None
157
186
187
+
158
188
class ThinkingEndEvent (BaseEvent ):
159
189
"""
160
190
Event indicating the end of a thinking step event.
161
191
"""
192
+
162
193
type : Literal [EventType .THINKING_END ] = EventType .THINKING_END # pyright: ignore[reportIncompatibleVariableOverride]
163
194
195
+
164
196
class StateSnapshotEvent (BaseEvent , Generic [AgentStateT ]):
165
197
"""
166
198
Event containing a snapshot of the state.
167
199
"""
200
+
168
201
type : Literal [EventType .STATE_SNAPSHOT ] = EventType .STATE_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
169
202
snapshot : AgentStateT
170
203
@@ -173,6 +206,7 @@ class StateDeltaEvent(BaseEvent):
173
206
"""
174
207
Event containing a delta of the state.
175
208
"""
209
+
176
210
type : Literal [EventType .STATE_DELTA ] = EventType .STATE_DELTA # pyright: ignore[reportIncompatibleVariableOverride]
177
211
delta : JSONValue # JSON Patch (RFC 6902)
178
212
@@ -181,6 +215,7 @@ class MessagesSnapshotEvent(BaseEvent):
181
215
"""
182
216
Event containing a snapshot of the messages.
183
217
"""
218
+
184
219
type : Literal [EventType .MESSAGES_SNAPSHOT ] = EventType .MESSAGES_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
185
220
messages : List [Message ]
186
221
@@ -189,6 +224,7 @@ class RawEvent(BaseEvent):
189
224
"""
190
225
Event containing a raw event.
191
226
"""
227
+
192
228
type : Literal [EventType .RAW ] = EventType .RAW # pyright: ignore[reportIncompatibleVariableOverride]
193
229
event : JSONValue
194
230
source : Optional [str ] = None
@@ -198,6 +234,7 @@ class CustomEvent(BaseEvent):
198
234
"""
199
235
Event containing a custom event.
200
236
"""
237
+
201
238
type : Literal [EventType .CUSTOM ] = EventType .CUSTOM # pyright: ignore[reportIncompatibleVariableOverride]
202
239
name : str
203
240
value : JSONValue
@@ -207,6 +244,7 @@ class RunStartedEvent(BaseEvent):
207
244
"""
208
245
Event indicating that a run has started.
209
246
"""
247
+
210
248
type : Literal [EventType .RUN_STARTED ] = EventType .RUN_STARTED # pyright: ignore[reportIncompatibleVariableOverride]
211
249
thread_id : str
212
250
run_id : str
@@ -216,6 +254,7 @@ class RunFinishedEvent(BaseEvent):
216
254
"""
217
255
Event indicating that a run has finished.
218
256
"""
257
+
219
258
type : Literal [EventType .RUN_FINISHED ] = EventType .RUN_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
220
259
thread_id : str
221
260
run_id : str
@@ -226,6 +265,7 @@ class RunErrorEvent(BaseEvent):
226
265
"""
227
266
Event indicating that a run has encountered an error.
228
267
"""
268
+
229
269
type : Literal [EventType .RUN_ERROR ] = EventType .RUN_ERROR # pyright: ignore[reportIncompatibleVariableOverride]
230
270
message : str
231
271
code : Optional [str ] = None
@@ -235,6 +275,7 @@ class StepStartedEvent(BaseEvent):
235
275
"""
236
276
Event indicating that a step has started.
237
277
"""
278
+
238
279
type : Literal [EventType .STEP_STARTED ] = EventType .STEP_STARTED # pyright: ignore[reportIncompatibleVariableOverride]
239
280
step_name : str
240
281
@@ -243,6 +284,7 @@ class StepFinishedEvent(BaseEvent):
243
284
"""
244
285
Event indicating that a step has finished.
245
286
"""
287
+
246
288
type : Literal [EventType .STEP_FINISHED ] = EventType .STEP_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
247
289
step_name : str
248
290
@@ -269,5 +311,5 @@ class StepFinishedEvent(BaseEvent):
269
311
StepStartedEvent ,
270
312
StepFinishedEvent ,
271
313
],
272
- Field (discriminator = "type" )
314
+ Field (discriminator = "type" ),
273
315
]
0 commit comments