Skip to content

Limits accepts negative or zero values without complaint #9

Description

@TheCoder30ec4

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

  • Invalid values raise ValueError
  • Tests in tests/test_models.py

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routingRouter, limits and the Jev requestbugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions