@@ -156,8 +156,6 @@ func (d *streamDecoder) decodeEvent(event responses.ResponseStreamEventUnion) ap
156156 return d .decodeReasoningSummaryTextDelta (event )
157157 case "response.output_text.annotation.added" :
158158 return d .decodeOutputTextAnnotationAdded (event )
159- case "response.text_annotation.delta" :
160- return d .decodeTextAnnotationDelta (event )
161159 case "error" :
162160 return d .decodeError (event )
163161 // Event types that we're aware of but don't yet expose to clients:
@@ -181,11 +179,32 @@ func (d *streamDecoder) decodeEvent(event responses.ResponseStreamEventUnion) ap
181179 "response.audio.done" ,
182180 "response.audio.transcript.delta" ,
183181 "response.audio.transcript.done" ,
184- "response.code_interpreter_call.code .delta" ,
185- "response.code_interpreter_call.code .done" ,
182+ "response.code_interpreter_call_code .delta" ,
183+ "response.code_interpreter_call_code .done" ,
186184 "response.code_interpreter_call.completed" ,
187185 "response.code_interpreter_call.in_progress" ,
188- "response.code_interpreter_call.interpreting" :
186+ "response.code_interpreter_call.interpreting" ,
187+ // Image generation events
188+ "response.image_generation_call.completed" ,
189+ "response.image_generation_call.generating" ,
190+ "response.image_generation_call.in_progress" ,
191+ "response.image_generation_call.partial_image" ,
192+ // MCP (Model Context Protocol) events
193+ "response.mcp_call_arguments.delta" ,
194+ "response.mcp_call_arguments.done" ,
195+ "response.mcp_call.completed" ,
196+ "response.mcp_call.failed" ,
197+ "response.mcp_call.in_progress" ,
198+ "response.mcp_list_tools.completed" ,
199+ "response.mcp_list_tools.failed" ,
200+ "response.mcp_list_tools.in_progress" ,
201+ // Additional reasoning events
202+ "response.reasoning.delta" ,
203+ "response.reasoning.done" ,
204+ "response.reasoning_summary.delta" ,
205+ "response.reasoning_summary.done" ,
206+ // Other events
207+ "response.queued" :
189208 // We're aware these events exist but we don't expose them to clients yet.
190209 return nil
191210 default :
@@ -335,40 +354,44 @@ func (d *streamDecoder) decodeResponseFailedOrIncomplete(event responses.Respons
335354
336355// decodeReasoningSummaryTextDelta handles reasoning summary text delta events
337356func (d * streamDecoder ) decodeReasoningSummaryTextDelta (event responses.ResponseStreamEventUnion ) api.StreamEvent {
357+ // Need to use the specific As method to get the event data
358+ reasoningDelta := event .AsResponseReasoningSummaryTextDelta ()
338359 return & api.ReasoningEvent {
339- TextDelta : event .Delta ,
360+ TextDelta : reasoningDelta .Delta ,
340361 }
341362}
342363
343364// decodeOutputTextAnnotationAdded handles response.output_text.annotation.added events
344365func (d * streamDecoder ) decodeOutputTextAnnotationAdded (event responses.ResponseStreamEventUnion ) api.StreamEvent {
345366 addedEvent := event .AsResponseOutputTextAnnotationAdded ()
346- if addedEvent .Annotation .Type == "url_citation" {
347- citation := addedEvent .Annotation .AsURLCitation ()
348- sourceEvent := & api.SourceEvent {
349- Source : api.Source {
350- SourceType : "url" ,
351- ID : fmt .Sprintf ("source-%d" , d .annotationCounter ),
352- URL : citation .URL ,
353- Title : citation .Title ,
354- },
355- }
356- d .annotationCounter ++
357- return sourceEvent
367+
368+ // Since Annotation is type 'any', we need to type assert it
369+ annotationMap , ok := addedEvent .Annotation .(map [string ]interface {})
370+ if ! ok {
371+ return nil
358372 }
359- return nil
360- }
361373
362- // decodeTextAnnotationDelta handles response.text_annotation.delta events
363- func (d * streamDecoder ) decodeTextAnnotationDelta (event responses.ResponseStreamEventUnion ) api.StreamEvent {
364- if event .Annotation .Type == "url_citation" {
365- citation := event .Annotation .AsURLCitation ()
374+ annotationType , ok := annotationMap ["type" ].(string )
375+ if ! ok {
376+ return nil
377+ }
378+
379+ if annotationType == "url_citation" {
380+ // Extract URL and Title from the annotation map
381+ url , urlOk := annotationMap ["url" ].(string )
382+ title , _ := annotationMap ["title" ].(string )
383+
384+ // Only create source event if we have at least a URL
385+ if ! urlOk || url == "" {
386+ return nil
387+ }
388+
366389 sourceEvent := & api.SourceEvent {
367390 Source : api.Source {
368391 SourceType : "url" ,
369392 ID : fmt .Sprintf ("source-%d" , d .annotationCounter ),
370- URL : citation . URL ,
371- Title : citation . Title ,
393+ URL : url ,
394+ Title : title , // Title can be empty, that's ok
372395 },
373396 }
374397 d .annotationCounter ++
0 commit comments