Skip to content

fix(simple_agent): call only the tools that the request declares - #5271

Draft
ffrujeri wants to merge 1 commit into
mainfrom
ffrujeri/simple-agent-declared-tools
Draft

ffrujeri wants to merge 1 commit into
mainfrom
ffrujeri/simple-agent-declared-tools

Conversation

@ffrujeri

Copy link
Copy Markdown
Contributor

What changed

simple_agent sends each function call that the model emits to <tool base URL>/<function name>. Until now it did not check the name against the tools that the request declares. Now it does:

  • A function call whose name is not one of the request's function tools gets the tool output {"error": "Unknown tool '<name>'"}, and no HTTP call is made. Invalid JSON arguments are already handled this way.
  • The declared tools are the request's function tools, including the function tools inside a namespace tool.
  • With trajectory collection on, the call is recorded as failed with error_type: "unknown_tool".

The check covers both paths: the direct HTTP tool grant of an agent session, and the resources_server configuration of /run.

Why

The function name is the last part of the tool URL, so the model chooses the URL path. A name that the request does not declare can reach any route of the Resources Server, with the episode's session cookie:

  • In the standard layout, tools sit at the server root next to /verify, /seed_session and /close_session. A function call named verify or close_session reaches those routes.
  • A grant whose base URL has a prefix does not help: ../verify resolves outside the prefix, because the URL path is normalized.

This came up in the review of #5202 (BIRD-Interact). There, an a-Interact agent could reach the c-Interact submit route with a function named ../submit and have its SQL graded without paying BIRD-COIN. #5202 adds mode checks for BIRD. This PR closes the general gap for every environment that runs on simple_agent.

There is no issue: the gap was found in the #5202 review, and this description records it.

Compatibility

Behavior changes only when the model calls a tool that the request does not declare. I checked the Resources Servers with catch-all tool routes that run on simple_agent. In each one, the change only affects the error text that the model sees, and no score depends on it directly:

Server Undeclared name before this PR Impact
math_advanced_calculations 404 "Function not found". The handler map is exactly the declared tools. Error text only
citation_if A fixed terminal response. max_steps: 1, and any function call fails the first gate. Error text only
ns_tools {"error": "Unknown tool: X"} Error text only
indirect_prompt_injection The handler map merges the tools of all nine domains, so a tool from another domain runs against the task's environment. Otherwise "Unknown tool". verify scores the function_call items, not their outputs, so the call still counts. The tool no longer runs, so later turns may differ.
nullable_tool_args {"status": "ok"} for any name. verify grades only the arguments of the first call. Error text only
workplace_assistant "Error executing tool 'X'". The map is the same 27 tools that rows declare, and the replay in verify skips unknown names. Error text only
partner_if (mock tools) 404 "Not a tool of this task". Its evidence code already treats calls that the harness rejects before any tool runs as the model's errors, if the output is a JSON object with an error key. This output is. Error text only
  • The catch-all servers that run on other agents are not affected: finance_agent_v2, finance_sec_search, conversational_tool_use_simulation, enterpriseops_gym and rna_design.
  • labbench2_vlm_agent and gdp_pdf_agent subclass SimpleAgent and get the check too.
  • Nine existing tests called tools that their requests did not declare. Their requests now declare them.
  • Not checked: full train and validation datasets, which might have rows that call tools described only in the prompt text. I sampled the example.jsonl files and found none that run on simple_agent.

Validation

Command Result
pytest responses_api_agents/simple_agent/tests/test_app.py 94 passed, 5 of them new. The four tests of refused calls (verify, ../verify, lookup/../../close_session, and a /run without a grant) fail on main. The namespace test passes on both.
pytest responses_api_agents/labbench2_vlm_agent/tests responses_api_agents/gdp_pdf_agent/tests (the two subclasses) 4 passed; 37 passed and 17 skipped
pytest tests/unit_tests -n 8, with the extras that CI installs 13871 passed, 8 failed. The same 8 fail on main on this workstation: three sandbox file-mode tests, four Harbor run-summary tests, and a benchmark-listing test whose configs do not resolve because the host name resolves to 127.0.1.1.
pre-commit run on the changed files passed

Rollout evidence

Not yet: this PR is a draft. Before review, I will run smoke rollouts on example_single_tool_call and two of the servers above, and compare rewards with main.

🤖 Generated with Claude Code

simple_agent posts each function call to <tool base URL>/<function name>
without checking the name against the request's tools. The model chooses
the URL path, so an undeclared name reaches any route of the Resources
Server with the episode's cookie: verify or close_session at the root,
or ../verify past a grant whose base URL has a prefix.

- Refuse a function call whose name is not one of the request's function
  tools, including the function tools of a namespace tool. The model
  gets an "Unknown tool" error as the tool output, and no HTTP call is
  made.
- Record the refused call as failed, with error_type unknown_tool.
- Declare the called tools in the nine tests whose requests did not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working labels Oct 29, 2026
@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test cfd475e

This branch was previously deployed

1 inactive deployment
public — cfd475e4 Deployed Oct 30, 2026 by copy-pr-bot[bot] via release / finalize / notify #8579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants