Skip to content

refactor(model_prices): move fallback_generalizations under sample_spec, above all models - #36416

Open
devin-ai-integration[bot] wants to merge 3 commits into
litellm_internal_stagingfrom
litellm_fallback_generalizations_top
Open

refactor(model_prices): move fallback_generalizations under sample_spec, above all models#36416
devin-ai-integration[bot] wants to merge 3 commits into
litellm_internal_stagingfrom
litellm_fallback_generalizations_top

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • New models keep landing after fallback_generalizations
  • That buries the rules block in the middle of the registry

How it solves it:

  • Moves the block up under sample_spec in both registry files
  • Appends now always land after it, never around it

User Flow

No end user flow changes. The block moves within the JSON, and key order carries no meaning for lookups, so both files parse to exactly the same content as before

Before: a maintainer adding a model appends it to the end of model_prices_and_context_window.json, which puts it after the fallback_generalizations block sitting in the middle of the file

  1. They open https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json and scroll to the bottom
  2. They add the entry there, below the rules block
  3. Review sees a model entry after a block that is not a model, and the rules drift further from the top of the file on every merge

After: the same append lands after every model entry and the rules stay put

  1. They open the same file and scroll to the bottom
  2. They add the entry there, with only model entries above it
  3. The rules block stays right under sample_spec no matter how many models get added later

Relevant issues

Linear ticket

Pre-Submission checklist

  • 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

Note on tests: this is a pure key reorder with no behavior to test, so no new tests were added. The existing tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py and test_fallback_generalizations.py already pin that the block is extracted from the map and never treated as a model entry, and both pass. The reorder was done with a script that asserts the parsed JSON is byte-for-byte equal in content to the previous revision

Screenshots / Proof of Fix

Content equality against the base revision, run at ba0d01a:

$ python3 - <<'EOF'
import json, subprocess
for path in ["model_prices_and_context_window.json", "litellm/model_prices_and_context_window_backup.json"]:
    old = json.loads(subprocess.run(["git","show",f"origin/litellm_internal_staging:{path}"],capture_output=True,text=True).stdout)
    new = json.load(open(path))
    print(path, "content identical:", old == new, "| first keys:", list(new)[:2])
EOF
model_prices_and_context_window.json content identical: True | first keys: ['sample_spec', 'fallback_generalizations']
litellm/model_prices_and_context_window_backup.json content identical: True | first keys: ['sample_spec', 'fallback_generalizations']

Type

🧹 Refactoring

Changes

fallback_generalizations moves directly below sample_spec in model_prices_and_context_window.json and its bundled backup, verbatim with no edits to any rule, so the doc placeholder stays first and every model entry sits below the rules. model_prices_and_context_window.schema.json is regenerated by ci_cd/generate_model_prices_schema.py so the generated file matches the new key order

A follow-up PR will pull the block out into its own JSON file with its own remote URL, which removes the ordering question entirely; this is the small fix in the meantime

Link to Devin session: https://app.devin.ai/sessions/b8d7e177e9144ff6a370b11e7e0e7c9c
Requested by: @mateo-berri

…he registry

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri mateo-berri self-assigned this Aug 10, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR moves the unchanged fallback_generalizations object to the beginning of both model-price registries so future model entries remain grouped below it.

  • Preserves the parsed registry contents.
  • Keeps the canonical and bundled backup registries synchronized.

Confidence Score: 5/5

The PR appears safe to merge because it only reorders an unchanged JSON object and current consumers handle the metadata by key rather than position.

The canonical loader removes fallback_generalizations by key before exposing model entries, and relevant validation and generation paths explicitly exclude the special root key, so moving it does not change runtime behavior.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Moves the unchanged fallback-generalization metadata from the final key to the first key without changing registry semantics.
litellm/model_prices_and_context_window_backup.json Applies the same content-preserving key reorder to the bundled backup registry.

Reviews (1): Last reviewed commit: "refactor(model_prices): move fallback_ge..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ons right below it

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot changed the title refactor(model_prices): move fallback_generalizations to the top of the registry refactor(model_prices): move fallback_generalizations under sample_spec, above all models Aug 10, 2026
@codspeed-hq

codspeed-hq Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fallback_generalizations_top (534a8a3) with litellm_internal_staging (9de3315)

Open in CodSpeed

…izations_top

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant