feat: extend tool_arg_contract with type checking (Closes #1529) - #1532
Closed
Lexus2016 wants to merge 1 commit into
Closed
feat: extend tool_arg_contract with type checking (Closes #1529)#1532Lexus2016 wants to merge 1 commit into
Lexus2016 wants to merge 1 commit into
Conversation
Add _check_type() helper and type validation to check_tool_args_contract(). Validates string, integer, number, boolean, array, object, null types against schema declarations. Adds ArgContractViolation.type_mismatch kind. Fail-open when no type declared. Default-OFF gating unchanged. Closes #1529 Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
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()to validate basic JSON Schema types (string, integer, number, boolean, array, object, null) in addition to the existingrequired+enumchecks.Changes
agent/tool_arg_contract.py: Added_SCHEMA_PY_TYPESmapping,_check_type()helper, andArgContractViolation.type_mismatchclassmethod. Type validation runs alongside enum checks in the existing property loop. Fail-open when notypedeclared.nulltype matches onlyNone.integerexplicitly excludesbool.tests/agent/test_tool_arg_contract.py: 13 new test cases covering type matches, mismatches, union types, fail-open cases, and combined type+enum violations.Context
requireddeclarations; the missing layer was type validationtools/tool_search.py:validate_tool_args()/_check_type()for discovered tools, now available at the native-tool composition boundaryHERMES_TOOL_ARG_CONTRACTenv ortool_arg_contract.enabledconfigChecklist
ruff check)ruff format --check)Closes #1529