Skip to content

Commit 790a507

Browse files
committed
Remove Unneeded Special Handling of OpenAPI Tool Calls
1 parent ea9c8ea commit 790a507

4 files changed

Lines changed: 8 additions & 41 deletions

File tree

assets/evaluators/builtin/tool_call_accuracy/evaluator/_tool_call_accuracy.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,14 +1086,6 @@ def _extract_needed_tool_definitions(self, tool_calls, tool_definitions):
10861086
built_in_definitions = _get_needed_built_in_definitions(tool_calls)
10871087
needed_tool_definitions.extend(built_in_definitions)
10881088

1089-
# OpenAPI tool is a collection of functions, so we need to expand it
1090-
tool_definitions_expanded = list(
1091-
chain.from_iterable(
1092-
tool.get("functions", []) if tool.get("type") == "openapi" else [tool]
1093-
for tool in needed_tool_definitions
1094-
)
1095-
)
1096-
10971089
# Validate that all tool calls have corresponding definitions
10981090
for tool_call in tool_calls:
10991091
if isinstance(tool_call, dict):
@@ -1107,7 +1099,7 @@ def _extract_needed_tool_definitions(self, tool_calls, tool_definitions):
11071099
elif tool_name:
11081100
# This is a regular function tool from converter or built-in tool from agent v2
11091101
tool_definition_exists = any(
1110-
tool.get("name") == tool_name for tool in tool_definitions_expanded
1102+
tool.get("name") == tool_name for tool in needed_tool_definitions
11111103
)
11121104
if not tool_definition_exists:
11131105
raise EvaluationException(

assets/evaluators/builtin/tool_input_accuracy/evaluator/_tool_input_accuracy.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -633,14 +633,6 @@ def _extract_needed_tool_definitions(
633633
built_in_definitions = _get_needed_built_in_tool_definitions(tool_calls)
634634
needed_tool_definitions.extend(built_in_definitions)
635635

636-
# OpenAPI tool is a collection of functions, so we need to expand it
637-
tool_definitions_expanded = list(
638-
chain.from_iterable(
639-
tool.get("functions", []) if tool.get("type") == "openapi" else [tool]
640-
for tool in needed_tool_definitions
641-
)
642-
)
643-
644636
# Validate that all tool calls have corresponding definitions
645637
for tool_call in tool_calls:
646638
if isinstance(tool_call, dict):
@@ -653,7 +645,7 @@ def _extract_needed_tool_definitions(
653645
continue
654646
elif tool_name:
655647
# This is a regular function tool from converter or built-in tool from agent v2
656-
tool_definition_exists = any(tool.get("name") == tool_name for tool in tool_definitions_expanded)
648+
tool_definition_exists = any(tool.get("name") == tool_name for tool in needed_tool_definitions)
657649
if not tool_definition_exists:
658650
raise EvaluationException(
659651
message=f"Tool definition for {tool_name} not found",

assets/evaluators/builtin/tool_selection/evaluator/_tool_selection.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,6 @@ def _extract_needed_tool_definitions(
731731
built_in_definitions = _get_needed_built_in_tool_definitions(tool_calls)
732732
needed_tool_definitions.extend(built_in_definitions)
733733

734-
# OpenAPI tool is a collection of functions, so we need to expand it
735-
tool_definitions_expanded = list(
736-
chain.from_iterable(
737-
tool.get("functions", []) if tool.get("type") == "openapi" else [tool]
738-
for tool in needed_tool_definitions
739-
)
740-
)
741-
742734
# Validate that all tool calls have corresponding definitions
743735
for tool_call in tool_calls:
744736
if isinstance(tool_call, dict):
@@ -751,7 +743,7 @@ def _extract_needed_tool_definitions(
751743
continue
752744
elif tool_name:
753745
# This is a regular function tool from converter or built-in tool from agent v2
754-
tool_definition_exists = any(tool.get("name") == tool_name for tool in tool_definitions_expanded)
746+
tool_definition_exists = any(tool.get("name") == tool_name for tool in needed_tool_definitions)
755747
if not tool_definition_exists:
756748
raise EvaluationException(
757749
message=f"Tool definition for {tool_name} not found",

assets/evaluators/tests/test_evaluators_behavior/test_tool_selection_evaluator_behavior.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ class TestToolSelectionEvaluatorBehavior(BaseToolCallEvaluatorBehaviorTest, Base
7373
"tool_definitions": data.FABRIC_TOOL_DEFINITIONS,
7474
}
7575

76-
# OpenAPI: ToolSelection flow is not called (no extractable tool calls)
77-
# Expected flow inputs not used since the test will not reach flow assertion
76+
test_openapi_expected_flow_inputs = {
77+
"query": data.OPENAPI_EXPECTED_FLOW_QUERY,
78+
"tool_calls": ["weather_GetCurrentWeather"],
79+
"tool_definitions": data.OPENAPI_TOOL_DEFINITIONS,
80+
}
7881

7982
test_web_search_expected_flow_inputs = {
8083
"query": data.WEB_SEARCH_EXPECTED_FLOW_QUERY,
@@ -116,15 +119,3 @@ class TestToolSelectionEvaluatorBehavior(BaseToolCallEvaluatorBehaviorTest, Base
116119
is_tool_definition_required = True
117120

118121
evaluator_type = ToolSelectionEvaluator
119-
120-
def test_openapi(self):
121-
"""OpenAPI: ToolSelection flow is not called (no extractable tool calls)."""
122-
results, flow_mock = self._run_evaluation_and_return_mocked_flow(
123-
query=data.OPENAPI_QUERY,
124-
response=data.OPENAPI_RESPONSE,
125-
tool_definitions=data.OPENAPI_TOOL_DEFINITIONS,
126-
)
127-
result_data = self._extract_and_print_result(results, "OpenAPI")
128-
self.assert_not_applicable(result_data)
129-
assert flow_mock is not None, "Flow mock should be set when use_mocking=True"
130-
flow_mock.assert_not_called()

0 commit comments

Comments
 (0)