Problem
Limits(output_tokens=-5, max_cost_usd=-1) is accepted. Negative output_tokens makes the context check more permissive than it should be, and a negative budget rejects everything with a confusing message.
Where
Limits in src/model_router/models.py.
Suggested fix
Add __post_init__ to the frozen dataclass:
output_tokens must be an int >= 1
max_cost_usd must be None or >= 0
Raise ValueError with a clear message.
Done when
Problem
Limits(output_tokens=-5, max_cost_usd=-1)is accepted. Negativeoutput_tokensmakes the context check more permissive than it should be, and a negative budget rejects everything with a confusing message.Where
Limitsinsrc/model_router/models.py.Suggested fix
Add
__post_init__to the frozen dataclass:output_tokensmust be an int >= 1max_cost_usdmust beNoneor >= 0Raise
ValueErrorwith a clear message.Done when
ValueErrortests/test_models.py