fix: validate routing limits on construction - #24
Merged
TheCoder30ec4 merged 2 commits intoSep 24, 2026
Merged
Conversation
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.
What does this change?
Fixes #9.
Limits(output_tokens=-5, max_cost_usd=-1)previously succeeded, letting invalid limits reach model filtering. Validate the arguments inLimits.__post_init__and raise a field-specificValueErrorimmediately.Require a positive integer output count and an optional nonnegative numeric budget. Reject booleans, invalid types, and NaN while preserving the defaults and zero budgets. Add regression tests and document the behavior in the README and changelog.
Related: #21 addresses the same issue. This implementation also covers the integer requirement, invalid types, and NaN, with boundary tests and user-facing documentation. Happy to consolidate with #21 if that is easier to review.
How was it tested?
On Windows with Python 3.13.3, using the pip/venv setup supported by CONTRIBUTING.md:
ValueErrorwas raised.python -m pytest -q: 69 passed, 22 subtests passed.python -m ruff check .: passed.python -m ruff format --check .: passed; all 14 Python files formatted.git diff --check: passed.Checklist
uv run pytest)..envcontents in the diff.Prepared with AI assistance. The tests and checks listed above were executed locally.