@@ -590,9 +590,7 @@ async def _run_stream() -> AsyncIterator[_messages.HandleResponseEvent]: # noqa
590590 text = '' # pragma: no cover
591591 if text :
592592 try :
593- self ._next_node = await self ._handle_text_response (
594- ctx , ctx .deps .tool_manager .validation_ctx , text , text_processor
595- )
593+ self ._next_node = await self ._handle_text_response (ctx , text , text_processor )
596594 return
597595 except ToolRetryError :
598596 # If the text from the preview response was invalid, ignore it.
@@ -656,9 +654,7 @@ async def _run_stream() -> AsyncIterator[_messages.HandleResponseEvent]: # noqa
656654
657655 if text_processor := output_schema .text_processor :
658656 if text :
659- self ._next_node = await self ._handle_text_response (
660- ctx , ctx .deps .tool_manager .validation_ctx , text , text_processor
661- )
657+ self ._next_node = await self ._handle_text_response (ctx , text , text_processor )
662658 return
663659 alternatives .insert (0 , 'return text' )
664660
@@ -720,14 +716,13 @@ async def _handle_tool_calls(
720716 async def _handle_text_response (
721717 self ,
722718 ctx : GraphRunContext [GraphAgentState , GraphAgentDeps [DepsT , NodeRunEndT ]],
723- validation_ctx : Any | Callable [[RunContext [DepsT ]], Any ],
724719 text : str ,
725720 text_processor : _output .BaseOutputProcessor [NodeRunEndT ],
726721 ) -> ModelRequestNode [DepsT , NodeRunEndT ] | End [result .FinalResult [NodeRunEndT ]]:
727722 run_context = build_run_context (ctx )
728- validation_context = build_validation_context (validation_ctx , run_context )
723+ validation_context = build_validation_context (ctx . deps . tool_manager . validation_ctx , run_context )
729724
730- result_data = await text_processor .process (text , run_context , validation_context )
725+ result_data = await text_processor .process (text , run_context = run_context , validation_context = validation_context )
731726
732727 for validator in ctx .deps .output_validators :
733728 result_data = await validator .validate (result_data , run_context )
0 commit comments