Skip to content

feat: extend tool_arg_contract with type checking (Closes #1529) - #1532

Closed
Lexus2016 wants to merge 1 commit into
mainfrom
evolution/issue-1529-type-check-v2
Closed

feat: extend tool_arg_contract with type checking (Closes #1529)#1532
Lexus2016 wants to merge 1 commit into
mainfrom
evolution/issue-1529-type-check-v2

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

Summary

Extends check_tool_args_contract() to validate basic JSON Schema types (string, integer, number, boolean, array, object, null) in addition to the existing required + enum checks.

Changes

  • agent/tool_arg_contract.py: Added _SCHEMA_PY_TYPES mapping, _check_type() helper, and ArgContractViolation.type_mismatch classmethod. Type validation runs alongside enum checks in the existing property loop. Fail-open when no type declared. null type matches only None. integer explicitly excludes bool.
  • 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

Checklist

  • Lint passes (ruff check)
  • Format passes (ruff format --check)
  • 45 tests pass (was 32, added 13)
  • Lines changed: 214 (additive, minimal surface)

Closes #1529

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>
@github-actions github-actions Bot added the bug Something isn't working label Jul 31, 2026
@Lexus2016

Copy link
Copy Markdown
Owner Author

Closing as duplicate: PR #1531 implements the same type-checking feature (Closes #1529) and additionally closes #1528 (schema audit). #1531 was merged to main. This v2 branch is superseded.

@Lexus2016 Lexus2016 closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] Extend tool_arg_contract to catch type mismatches (#1487 child B)

1 participant