Skip to content

ci(cost map): classify token_count_framing and token_count_fallback_model in the schema generator - #46784

Merged
mateo-berri merged 4 commits into
mainfrom
litellm_cost_map_schema_token_count_keys
Oct 16, 2026
Merged

mateo-berri merged 4 commits into
mainfrom
litellm_cost_map_schema_token_count_keys

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

User Flow

Before: a PR that adds the two token count keys to the cost map always fails the required Cost map guard

  1. A contributor opens a PR to main whose model_prices_and_context_window.json entries carry token_count_framing or token_count_fallback_model, with the generator key tables updated in the same PR
  2. The required "Cost map guard" check runs main's own generator, because the workflow uses pull_request_target
  3. It fails with "Unclassified keys in model_prices_and_context_window.json: token_count_fallback_model, token_count_framing"

After: the same PR passes the guard

  1. The contributor opens the same PR to main
  2. The required "Cost map guard" check runs main's generator, which now knows both keys
  3. It passes with "cost map guard passed (human PR, file checks only)"

Pre-Submission checklist

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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

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

Last updated: 8ae2d71. QA and /live-pr-risk ran on 6dd2eee, the last commit with a product diff

The client is the guard script itself, run the way the workflow runs it, against #46777's merge base (e65e5ab) and head (59ad554). Before is ci_cd/ from main at b907975, after is this branch's copy at 6dd2eee

Before (main b907975)

  1. python main-ci_cd/cost_map_guard.py --base e65e5abc4e --head 59ad554b2d --head-ref litellm_count_tokens_source_framing_fallback
cost map guard failed (human PR, file checks only):
- Unclassified keys in model_prices_and_context_window.json: token_count_fallback_model, token_count_framing. Add them to the key tables in generate_model_prices_schema.py and rerun it.
[exit 1]

After (this branch 6dd2eee)

  1. python ci_cd/cost_map_guard.py --base e65e5abc4e --head 59ad554b2d --head-ref litellm_count_tokens_source_framing_fallback
cost map guard passed (human PR, file checks only)
[exit 0]
  1. python ci_cd/generate_model_prices_schema.py --check on main's own cost map, showing the committed schema is unchanged
model_prices_and_context_window.schema.json is in sync and model_prices_and_context_window.json validates against it
[exit 0]
  • 6dd2eee passes /audit (skipped: CI tooling)

Type

🚄 Infrastructure

Caveats (if any)

Low

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

  • 6dd2eee passes /live-pr-risk


Note

Low Risk
CI/schema-generator-only change with no runtime behavior until a follow-up cost map PR uses the new keys.

Overview
Teaches the model prices schema generator about two upcoming cost-map fields so the required Cost map guard stops failing on PRs that add them.

token_count_framing is classified as a non-negative integer (per-request framing tokens for local count estimates). token_count_fallback_model is a non-empty string naming another model used when the provider cannot count tokens. Unit tests assert valid values pass and bad types/empty fallback names are rejected.

The committed model_prices_and_context_window.schema.json stays unchanged until entries actually use these keys.

Reviewed by Cursor Bugbot for commit 8ae2d71. Bugbot is set up for automated code reviews on this repo. Configure here.

@devin-ai-integration

devin-ai-integration Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

No correctness findings.

Checks and execution details
  • Passed · Real testing evidence (required): Not applicable: no LLM translation changes in the scoped paths. The diff changes only ci_cd/generate_model_prices_schema.py and tests/unit/test_model_prices_schema.py. Neither path is under litellm/llms/** or litellm/litellm_core_utils/prompt_templates/**.
  • Passed · Schema generator unit tests (optional): python -m pytest tests/unit/test_model_prices_schema.py -q passed with 99 tests after installing the repo and its test dependencies. This covers the new tests for valid framing values 0 and 78, and for rejecting -1, "78", 1.5, an empty fallback model and a non-string fallback model.
  • Passed · Committed schema in sync (optional): python ci_cd/generate_model_prices_schema.py --check printed model_prices_and_context_window.schema.json is in sync and model_prices_and_context_window.json validates against it.

View review · Reviewed 8ae2d7196863

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8ae2d71. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot

@litellm-stampbot

Copy link
Copy Markdown

litellm-stampbot: risk low

Approved at 8ae2d71.

Rules (stampbot/risk_rules.yml):

  • low: no rule flagged it

Judge (gpt-6-luna): low, probability of high 0.00 (high at or above 0.90)

  • risk: low (probability of high 0.00)

Pushes do not re-run this check. Comment @litellm-stampbot again to re-check the new head.

@litellm-stampbot litellm-stampbot Bot added the risk:low Small, isolated, low-risk change label Oct 16, 2026

@kerry-berri kerry-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low risk by rule and by judgement at 8ae2d71

@mateo-berri
mateo-berri merged commit c6a4437 into main Oct 16, 2026
89 of 90 checks passed
@mateo-berri
mateo-berri deleted the litellm_cost_map_schema_token_count_keys branch October 16, 2026 00:30
mateo-berri added a commit that referenced this pull request Oct 19, 2026
Keep #43900, #45301, #46121, #46784, #46759, #46767, #46772, #46815, #47057 and #46777. Port only the Gemini prerequisites from #46430.

Remove the deferred Bedrock Mantle behavior and unrelated picks from the final tree. Restore the PDF test provider fixture and deployment, and retain required test imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Small, isolated, low-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants