feat: extend tool_arg_contract to catch type mismatches (Closes #1528, #1529) - #1531
Merged
Conversation
Add basic type checking (string, integer, number, boolean, array, object) to check_tool_args_contract(), mirroring the existing validate_tool_args() logic in tools/tool_search.py. Type violations produce ArgContractViolation with kind='type_mismatch'. Default-OFF gating unchanged. Also completes #1528 (audit): all 8 native tools already have required arrays and type declarations — no schema fixes needed. Closes #1528 Closes #1529 Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
This was referenced Jul 31, 2026
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
Extends
check_tool_args_contract()inagent/tool_arg_contract.pyto validate basic types (string, integer, number, boolean, array, object) against the schema'stypedeclaration, mirroring the existingvalidate_tool_args()logic intools/tool_search.pyso native tools get the same type guard already available to discovered tools.Changes
agent/tool_arg_contract.py(+75 insertions, -6 deletions):ArgContractViolation.type_mismatch()classmethod_SCHEMA_PY_TYPESdict and_check_type()helper (mirrorstools.tool_search)check_tool_args_contract()— runs after enum check, validates each present arg against its declaredtypetool_arg_contract_enabled()not modified)tests/agent/test_tool_arg_contract.py(+104 insertions, 0 deletions):#1528 Audit Results
All 8 native tools (terminal, search_files, tool_call, write_file, patch, browser_console, execute_code, process) already have
requiredarrays andtypedeclarations on all properties. No schema fixes needed — all tools are already contract-check compatible.Design Decisions
boolis subclass ofint— explicitly rejected forintegerparams (isinstance(value, int) and not isinstance(value, bool))True(don't block dispatch)["string", "integer"]list_SCHEMA_PY_TYPESand_check_type()kept local (not imported fromtools.tool_search) to maintain the module's dependency-free design like its siblingsagent.verify_policy/agent.policy_interceptorsLine count
185 total changed lines (75+6 + 104+0) — within 200-line self-merge cap.
Checks
Closes #1528
Closes #1529
Co-Authored-By: Hermes Evolution evolution@hermes.ai