File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
src/agentex/lib/core/temporal/plugins/openai_agents/models Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -826,6 +826,8 @@ async def get_response(
826826 # Serialize response output items for span tracing
827827 new_items = []
828828 final_output = None
829+ tool_calls = []
830+ tool_outputs = []
829831
830832 for item in response_output :
831833 try :
@@ -845,12 +847,38 @@ async def get_response(
845847 logger .warning (f"Failed to serialize item in temporal_streaming_model: { e } " )
846848 continue
847849
850+ # Extract tool calls and outputs from input
851+ try :
852+ if isinstance (input , list ):
853+ for item in input :
854+ try :
855+ item_dict = _serialize_item (item ) if not isinstance (item , dict ) else item
856+ if item_dict :
857+ # Capture function calls
858+ if item_dict .get ('type' ) == 'function_call' :
859+ tool_calls .append (item_dict )
860+ # Capture function outputs
861+ elif item_dict .get ('type' ) == 'function_call_output' :
862+ tool_outputs .append (item_dict )
863+ except Exception :
864+ pass
865+ except Exception as e :
866+ logger .warning (f"Failed to extract tool calls and outputs: { e } " )
867+
848868 # Set span output with structured data
849869 if span :
850- span . output = {
870+ output_data = {
851871 "new_items" : new_items ,
852872 "final_output" : final_output ,
853873 }
874+ # Include tool calls if any were in the input
875+ if tool_calls :
876+ output_data ["tool_calls" ] = tool_calls
877+ # Include tool outputs if any were processed
878+ if tool_outputs :
879+ output_data ["tool_outputs" ] = tool_outputs
880+
881+ span .output = output_data
854882
855883 # Return the response
856884 return ModelResponse (
You can’t perform that action at this time.
0 commit comments