Skip to content

Commit 456e1bc

Browse files
lesebclaude
andcommitted
refactor(responses): make web_search its own elif branch in tool executor
Move web_search config injection from nested inside the else catch-all to a proper elif branch, consistent with the MCP and file_search tool handling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sébastien Han <seb@redhat.com>
1 parent 8632a93 commit 456e1bc

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/ogx/providers/inline/responses/builtin/responses/tool_executor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,8 @@ async def _execute_tool(
378378
query=query,
379379
response_file_search_tool=response_file_search_tool,
380380
)
381-
else:
382-
# For web_search, inject config from response_tools into kwargs
383-
if function_name == "web_search" and ctx.response_tools:
381+
elif function_name == "web_search":
382+
if ctx.response_tools:
384383
response_web_search_tool = next(
385384
(t for t in ctx.response_tools if isinstance(t, OpenAIResponseInputToolWebSearch)),
386385
None,
@@ -395,12 +394,13 @@ async def _execute_tool(
395394
if response_web_search_tool.search_context_size:
396395
tool_kwargs["search_context_size"] = response_web_search_tool.search_context_size
397396

398-
attributes = {
399-
"tool_name": function_name,
400-
}
401-
# TODO: follow semantic conventions for Open Telemetry tool spans
402-
# https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/#execute-tool-span
403-
with tracer.start_as_current_span("invoke_tool", attributes=attributes):
397+
with tracer.start_as_current_span("invoke_tool", attributes={"tool_name": function_name}):
398+
result = await self.tool_runtime_api.invoke_tool(
399+
tool_name=function_name,
400+
kwargs=tool_kwargs,
401+
)
402+
else:
403+
with tracer.start_as_current_span("invoke_tool", attributes={"tool_name": function_name}):
404404
result = await self.tool_runtime_api.invoke_tool(
405405
tool_name=function_name,
406406
kwargs=tool_kwargs,

0 commit comments

Comments
 (0)