Commit Graph

5 Commits

Author SHA1 Message Date
Teknium
fa57c687c1 fix(tools): a closed schema that omits properties still refuses extras
Adolanium review on 658bd6d3: a plugin may close a no-argument schema as
{"type": "object", "additionalProperties": false} with no properties
member. The guard skipped it, so a wrapped call still ran with defaults.
An omitted properties now declares none; a non-dict one stays skipped.

Also: names a plugin's dynamic served schema adds are never refused
(the model was offered them), and call_with_arg_checks' docstring
describes the refusal it now makes.
2026-11-11 18:52:25 -08:00
Teknium
ce029b91f8 fix(tools): closed-schema MCP/plugin tools refuse undeclared arguments
A third-party tool whose schema closes the object (additionalProperties:
false) promises the exact argument set. zod/pydantic-backed MCP servers
emit that form yet strip unknown keys at parse time, so a misspelled or
wrapped call ran with defaults and returned a normal success; the model
never learned and repeated the shape all session.

The check now lives in tools/arg_validation.py beside the built-in
required/unknown checks that landed in #153189, so it runs on the same
seams (registry dispatch, inline executors). Built-in tools keep their
warn-and-run contract; open and union-shaped schemas are untouched.

Live on @playwright/mcp (25/25 tools closed): main ran
browser_console_messages(levle="error") and returned a default result;
this refuses it naming level, all, filename.

Port of RooCodeInc/Roomote#2695; reworked onto #153189's module.
2026-11-11 18:52:25 -08:00
Teknium
85c80cdeae fix(tools): leave required arguments a handler does without to the handler
Independent review found three calls that work on main and were refused:
vision_analyze and video_analyze without a question (the native-image
route loads the image as-is), react_to_message without an emoji (that
retracts the reaction) and search_files listing files without a pattern.
Those required keys are now self-checked. search_files itself refuses a
content search without a pattern, since an empty pattern matches every
line and returns the whole tree as "results".

A tool's own structured _warning is no longer overwritten by the
unknown-argument note.
2026-11-10 22:29:30 -08:00
Teknium
b1c9f938e3 fix(tools): flag unknown delegate_task arguments on the sequential path too
Review follow-up:
- the sequential executor called the delegate handler directly, so an unknown
  delegate_task argument was still dropped silently there while the concurrent path
  and registry dispatch flagged it;
- the unknown-argument warning was skipped whenever the handler's error text happened
  to contain the argument's name (an action list naming `log` hid a stray `log=`
  argument). The warning is now always attached;
- the MCP control in the test used a handler defined in the test module, which the
  built-in check already excludes; it now registers a `tools` handler under an `mcp-*`
  toolset so it fails if that exemption is removed (checked).
2026-11-10 22:29:30 -08:00
Teknium
8300964930 feat(tools): refuse built-in tool calls missing a required argument, flag unknown ones
A call such as search_files without `pattern` ran anyway and returned matches, and a
typo'd or invented argument was dropped with no signal, so the model assumed an option
had taken effect. One check now sits in front of every tool Hermes ships
(registry dispatch and the agent's inline executors; model_tools.py is untouched):

- a missing `required` argument is refused before the handler runs, naming the field
  (with its allowed values when the schema enumerates them) and the valid parameters;
- an argument the schema does not declare still reaches the handler exactly as sent;
  the result gains a `_warning` naming it. Nothing is stripped.

Slim redo of #142503. What differs from it, and why:

- scope is built-in tools only. MCP and plugin tools, and schemas that are open or
  union-shaped at the root, pass through untouched: a third-party `properties` list is
  not a promise about what the handler accepts.
- nothing is stripped, so handlers that read an undeclared key and execution middleware
  that rewrites arguments keep main's contract.
- legacy call shapes and tool-owned guidance are declared by each tool at registration
  (`compat_args`, `self_checked_args`) instead of a central table: skill_manage and memory
  flat shapes, delegate_task's single-task shape, patch's V4A mode, terminal(code=...),
  video_generate(video_url=...), and the handlers whose own missing-argument message says
  more than a generic refusal can.
- the dynamic schema is only built when the registered one reports a finding.

Co-authored-by: Elisa Martinez Abad <elisam@nvidia.com>
Co-authored-by: James Nolan <jnolan@nvidia.com>
2026-11-10 22:29:30 -08:00