Repository navigation
fix(tools): report undeclared params instead of silently dropping them - #330
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
`_cast_object` discarded any argument the tool's schema did not declare, so a caller that invented a field got a normal-looking success and repeated the mistake. Report the key instead, and give every rejection one shape: an error code, which contract was violated, one line per offending field (carrying the accepted values where the schema declares them), and an explicit "nothing was run". The pre-check itself already existed — `prepare_call` returned before `execute`. What is new is that unknown keys now reach that check at all. Message shape ported from the Rotifer Protocol CLI (measured 2026-11-27). An A/B against deepseek-flash did NOT show a correction-rate gain (OLD 19/20 vs NEW 20/20, Wilson intervals overlapping), so this stands on correctness — silently altering the caller's input — not on measured model behaviour. Tests: tests/test_tool_schema_precheck.py (10 cases).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prepare_callalready rejected a tool call whose parameters failed validation, beforeexecute. It did not reject — or even mention — undeclared keys:_cast_objectdropped them, so a caller that invented a field got a normal-looking success and repeated the same malformed call.That is a correctness problem, not a crash: the caller's input was silently altered. This change reports the unknown keys and gives every rejection one message shape.
Changes
core/agent_runtime/tools/base.pyformat_invalid_input(tool_name, errors)— one message:Error: INVALID_INPUT, the violated contract, one line per offending field (carrying the accepted values where the schema declares them), thenNothing was run. Fix the field(s) above and call <tool> again.Tool.unknown_param_names(params)— keys the schema never declared, honouring the same escape hatches_cast_objecthonours (noproperties, oradditionalProperties: true).core/agent_runtime/tools/registry.pyprepare_calllists unknown keys first, then validation errors, and routes both throughformat_invalid_input.tests/test_tool_schema_precheck.py(new, 10 cases) — strict and pass-through tools; unknown keys are reported and never reachexecute; invalid enum values carry the accepted set; free-form schemas stay unchanged.Compatibility
execute(they never were) — they are now named in the rejection instead of being dropped silently.additionalProperties: truetools accept the same inputs as before.Note on measured effect
The message shape is ported from the Rotifer Protocol CLI. An A/B against deepseek-flash did not show a correction-rate gain (19/20 old vs 20/20 new, Wilson intervals overlapping), so this stands on correctness — not altering the caller's input silently — rather than on a measured model-behaviour win.
Tests
10 passedon a clean worktree ofmainatc0395516;pre-commit run --files …(ruff 0.15.21 + ruff-format) clean.Unrelated:
tests/test_agent_runner_kernel.py::test_environment_context_is_resolved_and_xml_safefails on this Windows checkout on the base commit too (XML escaping of a temp path containing&); it is not touched by this PR.