Repository navigation
Python: fix(core): reject booleans and non-integers for FunctionTool invocation limits - #8696
Conversation
…on limits Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
|
Thank you for proposing this change. I am closing this PR for now because it has no linked issue, and I could not find an issue covering this specific problem. Our contribution guidelines ask contributors to create or reuse an issue and discuss the approach before nontrivial changes (with an exception for trivial changes). The repository PR template asks for Motivation & Context, Description & Review Guide, a Related Issue linked with a closing keyword such as |
In FunctionTool.init, max_invocations and max_invocation_exceptions were only validated with a less-than-1 comparison. Because bool is a subclass of int in Python, passing True bypassed the check because True is not less than 1, causing the limit to be silently set to 1. Passing False resulted in an unclear error message rather than rejecting the boolean type. Non-integers like floats or strings were also not rejected upfront.
This PR updates FunctionTool.init so that provided limits must be non-boolean integers of at least 1. I also added unit tests in test_tools.py verifying both the type validation and invocation limit enforcement.