Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inference_endpoint/evaluation/bfcl_v4_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def process_response(
model_responses_bfcl = []
for tc in tool_calls:
name = tc["name"]
if allowed_names and name not in allowed_names:
if name not in allowed_names:
logger.warning(
"Dropping tool call to undeclared function %r for %s turn "
"%d (not in the entry's tool list); refusing to execute an "
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/evaluation/test_bfcl_v4_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _state(entry_id="multi_turn_base_0", max_steps=25):
current_step=0,
current_turn_results=[],
messages=[],
tools=[],
tools=[{"type": "function", "function": {"name": "f"}}],
force_terminated=False,
completed=False,
model_results_per_turn=[],
Expand Down Expand Up @@ -112,14 +112,18 @@ def test_process_response_no_tool_calls_advances_turn():


@pytest.mark.unit
def test_process_response_drops_undeclared_tool_name():
@pytest.mark.parametrize(
"tools",
[[{"type": "function", "function": {"name": "f"}}], [], [{"type": "function"}]],
)
def test_process_response_drops_undeclared_tool_name(tools):
"""A tool call to a name the entry never declared must not reach bfcl-eval's
executor (guards against injection like __import__('os').system)."""
executed = []
bridge = _make_bridge()
state = _state()
state.entry.num_turns = 1
state.tools = [{"type": "function", "function": {"name": "f"}}]
state.tools = tools
with (
patch.object(ex, "convert_to_function_call", lambda calls: list(calls)),
patch.object(ex, "is_empty_execute_response", lambda d: len(d) == 0),
Expand Down
Loading