Skip to content

test(router): assert the auto-router max_input_chars kwarg - #36109

Merged
yuneng-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_/xenodochial-cannon-ffc974
Aug 7, 2026
Merged

test(router): assert the auto-router max_input_chars kwarg#36109
yuneng-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_/xenodochial-cannon-ffc974

Conversation

@yuneng-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Add the missing kwarg to the expected constructor call
  • Assert the shared constant, not the literal 2000

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

This PR is test-only. git diff --stat c1fa15132b..HEAD touches exactly one file under tests/, no runtime code, so there is no proxy behavior to curl before and after: the routing behavior the assertion guards is identical on both commits

Before, on litellm_internal_staging at c1fa15132b with no local changes:

$ PYTHONPATH=$PWD python -m pytest tests/router_unit_tests/test_router_helper_utils.py -q
FAILED tests/router_unit_tests/test_router_helper_utils.py::test_init_auto_router_deployment_success
1 failed, 141 passed, 8 warnings in 114.13s (0:01:54)

with

E  Expected: AutoRouter(..., litellm_router_instance=<litellm.router.Router object at 0x11dd68c20>)
E    Actual: AutoRouter(..., litellm_router_instance=<litellm.router.Router object at 0x11dd68c20>, max_input_chars=2000)

After, at 495eb7e7f4:

$ PYTHONPATH=$PWD python -m pytest tests/router_unit_tests/test_router_helper_utils.py -q
142 passed, 8 warnings in 93.58s (0:01:33)

To confirm the updated assertion still has teeth rather than just matching whatever the code does, I dropped max_input_chars= from the AutoRouter(...) call in litellm/router.py at 495eb7e7f4 and reran, and the test went red again:

FAILED tests/router_unit_tests/test_router_helper_utils.py::test_init_auto_router_deployment_success
1 failed in 0.13s

Type

✅ Test

Changes

#35956 gave AutoRouter.__init__ a max_input_chars parameter and started passing it from Router.init_auto_router_deployment, which caps how much of a prompt reaches the embedding model. That change was intentional and stays as is. What it missed was tests/router_unit_tests/test_router_helper_utils.py, whose assert_called_once_with on the constructor still spelled out the old kwarg set, so the test has been red on staging ever since and is unrelated to whatever branch a contributor happens to be on

The passthrough is already covered behaviorally by TestAutoRouterMaxInputCharsWiring in tests/test_litellm/test_router.py, which asserts both that a deployment's auto_router_max_input_chars reaches the registered AutoRouter and that omitting it falls back to the shared default. Duplicating that here would add no signal, so this PR only brings the stale expectation back in line. It asserts DEFAULT_AUTO_ROUTER_MAX_INPUT_CHARS instead of hardcoding 2000 so that tuning the default does not break this test a second time

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

PR #35956 added the max_input_chars passthrough to the AutoRouter
constructor but left this mock assertion in tests/router_unit_tests
unchanged, so test_init_auto_router_deployment_success has been failing
on litellm_internal_staging ever since.

The passthrough itself is intentional and its behaviour is already
covered by TestAutoRouterMaxInputCharsWiring in tests/test_litellm, so
only the stale expected kwargs need updating. Assert the shared constant
rather than the literal 2000 so tuning the default does not break this
test again.
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This test-only PR updates the AutoRouter constructor assertion to include the shared default input-character limit.

  • Imports DEFAULT_AUTO_ROUTER_MAX_INPUT_CHARS.
  • Verifies that Router.init_auto_router_deployment passes the shared default to AutoRouter.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable defects identified.

The changed assertion now matches the intentional AutoRouter default passthrough, while separate tests continue to cover both configured and fallback values.

Important Files Changed

Filename Overview
tests/router_unit_tests/test_router_helper_utils.py Correctly updates the stale mock assertion using the shared constant without weakening coverage or changing runtime behavior.

Reviews (1): Last reviewed commit: "test(router): assert the auto-router max..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yuneng-berri
yuneng-berri enabled auto-merge August 7, 2026 00:47
@yuneng-berri
yuneng-berri merged commit a79d9ba into litellm_internal_staging Aug 7, 2026
75 of 76 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_/xenodochial-cannon-ffc974 branch August 7, 2026 00:47
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