@@ -764,6 +764,11 @@ async def _consume_event_queue(
764764 f'Unexpected node event queue item: { type (event_or_done ).__name__ } '
765765 )
766766 event = event_or_done
767+ output_event = await self ._process_event_with_plugin_callbacks (
768+ invocation_context = ic ,
769+ event = event ,
770+ )
771+
767772 # When an LlmAgent node uses ``message_as_output`` (no
768773 # ``output_schema``), the wrapper sets both ``event.content``
769774 # (the model's text) AND ``event.output`` (the same text) to
@@ -772,17 +777,14 @@ async def _consume_event_queue(
772777 # surface the same text twice. Task-mode agents set
773778 # ``event.output`` from the ``finish_task`` FC args without
774779 # ``message_as_output``, so this clearing doesn't affect them.
775- if not event .partial :
776- if event .node_info .message_as_output and event .content is not None :
777- event = event .model_copy ()
778- event .output = None
779-
780- output_event = await self ._process_event_with_plugin_callbacks (
781- invocation_context = ic ,
782- event = event ,
783- )
784-
785- if not event .partial :
780+ if not output_event .partial :
781+ if (
782+ output_event .node_info
783+ and output_event .node_info .message_as_output
784+ and output_event .content is not None
785+ ):
786+ output_event = output_event .model_copy ()
787+ output_event .output = None
786788 await self .session_service .append_event (
787789 session = ic .session , event = output_event
788790 )
@@ -1442,7 +1444,7 @@ async def _exec_with_plugin(
14421444 invocation_context = invocation_context ,
14431445 event = early_exit_event ,
14441446 )
1445- if self ._should_append_event (early_exit_event , is_live_call ):
1447+ if self ._should_append_event (output_event , is_live_call ):
14461448 await self .session_service .append_event (
14471449 session = invocation_context .session ,
14481450 event = output_event ,
@@ -1461,15 +1463,16 @@ async def _exec_with_plugin(
14611463
14621464 if is_live_call :
14631465 # Skip partial transcriptions for Live
1464- if event .partial is not True and self ._should_append_event (
1465- event , is_live_call
1466+ if (
1467+ output_event .partial is not True
1468+ and self ._should_append_event (output_event , is_live_call )
14661469 ):
14671470 logger .debug ('Appending live event: %s' , output_event )
14681471 await self .session_service .append_event (
14691472 session = invocation_context .session , event = output_event
14701473 )
14711474 else :
1472- if event .partial is not True :
1475+ if output_event .partial is not True :
14731476 await self .session_service .append_event (
14741477 session = invocation_context .session , event = output_event
14751478 )
0 commit comments