@@ -106,6 +106,11 @@ async def handle_call(
106106 """
107107 if self .tools is None or self .ctx is None :
108108 raise ValueError ('ToolManager has not been prepared for a run step yet' ) # pragma: no cover
109+
110+ if (tool := self .tools .get (call .tool_name )) and tool .tool_def .kind == 'output' :
111+ output_tool_flag = True
112+ else :
113+ output_tool_flag = False
109114
110115 return await self ._call_function_tool (
111116 call ,
@@ -116,6 +121,7 @@ async def handle_call(
116121 include_content = self .ctx .trace_include_content ,
117122 instrumentation_version = self .ctx .instrumentation_version ,
118123 usage = self .ctx .usage ,
124+ output_tool_flag = output_tool_flag ,
119125 )
120126
121127 async def _call_tool (
@@ -204,16 +210,17 @@ async def _call_function_tool(
204210 include_content : bool ,
205211 instrumentation_version : int ,
206212 usage : RunUsage ,
213+ output_tool_flag : bool = False ,
207214 ) -> Any :
208215 """See <https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/#execute-tool-span>."""
209216 instrumentation_names = InstrumentationNames .for_version (instrumentation_version )
210217
211- if (tool := self .tools .get (call .tool_name )) and tool .tool_def .kind == 'output' :
212- tool_name : str = 'Output Tool'
213- output_tool_flag = True
218+ if output_tool_flag :
219+ tool_name = 'output tool'
214220 else :
215- tool_name : str = call .tool_name
216- output_tool_flag = False
221+ tool_name = call .tool_name
222+
223+
217224
218225 span_attributes = {
219226 'gen_ai.tool.name' : tool_name ,
0 commit comments