File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -850,6 +850,24 @@ async def dispatch_stream_events() -> None:
850850 if custom_output_extractor :
851851 return await custom_output_extractor (run_result )
852852
853+ if run_result .final_output is not None and (
854+ not isinstance (run_result .final_output , str ) or run_result .final_output != ""
855+ ):
856+ return run_result .final_output
857+
858+ from .items import ItemHelpers
859+
860+ text_output = ItemHelpers .text_message_outputs (run_result .new_items )
861+ if text_output :
862+ return text_output
863+
864+ for item in reversed (run_result .to_input_list ()):
865+ if item .get ("type" ) != "function_call_output" :
866+ continue
867+ output = item .get ("output" )
868+ if isinstance (output , str ) and output :
869+ return output
870+
853871 return run_result .final_output
854872
855873 run_agent_tool = _build_wrapped_function_tool (
You can’t perform that action at this time.
0 commit comments