Skip to content

Conversation

@rasdani
Copy link
Contributor

@rasdani rasdani commented Dec 31, 2025

Description

  • Filters function signature before schema generation to avoid strict JSON schema validation errors on skipped parameters
  • Parameters with dict type (which produce additionalProperties: true) no longer cause validation failures when listed in args_to_skip

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes


Note

Fixes schema generation for skipped tool args by filtering function signatures before conversion.

  • Introduces filter_signature to remove skipped params (and annotations, incl. self) prior to convert_func_to_oai_tool
  • Updates StatefulToolEnv.add_tool to use the filtered signature so dict-typed skipped args no longer appear in parameters
  • Adds test test_add_tool_skips_dict_type_args verifying dict param omission from the schema

Written by Cursor Bugbot for commit 4dd6eb3. This will update automatically on new commits. Configure here.

target.__annotations__ = {
k: v for k, v in target.__annotations__.items() if k not in args_to_skip
}
return func
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter_signature mutates original function signature permanently

The filter_signature function permanently modifies the original function's __signature__ and __annotations__ attributes in place. This causes side effects when the same function is reused elsewhere or added to multiple StatefulToolEnv instances with different args_to_skip. For example, if add_tool(my_func, args_to_skip=["a"]) is called, then my_func is permanently altered, so any subsequent inspection or use of that function will see the modified signature. This affects module-level functions (like secret_tool in tests) and bound methods. The function should work on a copy or wrapper rather than mutating the original.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants