fix(schema): classify off_peak_pricing as a structured object in the model prices schema generator - #41847
Conversation
…model prices schema generator Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
|
…ricing Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Pushed 4b215e2 fixing both Greptile findings: window strings and weekday names are now pattern checked, and a block must carry a schedule |
|
osv-scan failure is unrelated to this PR: a new anyio 4.13.0 advisory (GHSA-82r6-8w77-94w6) fails osv-scan on every open PR, including #41838 and #41814. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…peak_pricing_schema
…peak_pricing_schema
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
There was a problem hiding this comment.
✅ 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 7208e31. Configure here.
TLDR
Problem this solves:
off_peak_pricingas an unclassified keyHow it solves it:
off_peak_pricingtoOBJECT_KEYSas a structured object schemaOffPeakPricingTypedDict:hours_utc,windows,weekday_timezone, five override ratesHH:MM-HH:MM, weekday names must be ones the runtime recognizes, and a block needshours_utcorwindowsUser Flow
Before: the price sync bot cannot publish an openrouter catalog update that carries an off-peak rate block
python ci_cd/generate_model_prices_schema.pyon that catalog prints "Unclassified keys in model_prices_and_context_window.json: off_peak_pricing" and no PR is openedAfter: the same catalog validates and the sync can publish
python ci_cd/generate_model_prices_schema.pyrendersoff_peak_pricingas an object withhours_utc,windows,weekday_timezoneand the override rates, and the catalog validates against the resultRelevant issues
Companion change in BerriAI/litellm-providers keeps the sync side's schema classification identical to this generator
Affected release
Linear ticket
Resolves LIT-8128
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<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@greptileaito 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 change only touches the schema generator that CI and the price sync run, so the proof is the generator itself, run in a worktree at each commit against the current catalog plus one entry carrying an off-peak block:
Before (db756b9)
python ci_cd/generate_model_prices_schema.py --checkUnclassified keys in model_prices_and_context_window.json: off_peak_pricing. Add them to the key tables in generate_model_prices_schema.py and rerun it.After (4b215e2)
python ci_cd/generate_model_prices_schema.py --checkmodel_prices_and_context_window.schema.json is out of sync with model_prices_and_context_window.json. Run python ci_cd/generate_model_prices_schema.py and commit the result.(the key is classified; the committed schema simply does not yet carry it because no entry onmainuses it)python ci_cd/generate_model_prices_schema.pythen--checkagain:model_prices_and_context_window.schema.json is in sync and model_prices_and_context_window.json validates against itOn the unmodified
maincatalog--checkstill passes at the PR tip, so the committed schema is unchanged by this PRType
🐛 Bug Fix
Caveats (if any)
Low
off_peak_pricingFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/b3650eb76464401f9bd6e0e7264bf62b
Open in Devin Desktop: https://app.devin.ai/desktop/session/b3650eb76464401f9bd6e0e7264bf62b?variant=devin
Note
Low Risk
CI/schema-generator and test-only changes; no runtime billing logic is modified, only validation rules for catalog JSON.
Overview
Teaches the model-prices schema generator to recognize
off_peak_pricinginstead of failing catalog validation when OpenRouter (or other) entries include time-of-day rate overrides.The new object schema matches the runtime shape: optional
hours_utc(single or list ofHH:MM-HH:MMUTC windows, including midnight wrap) orwindowswith per-windowweekdays(ISO 1–7 or English day names) and optionalweekday_timezone, plus nonnegative overrides for input/output/reasoning/cache token costs. Blocks must supplyhours_utcorwindows, and unknown keys are rejected.Tests assert a representative off-peak entry validates and that common malformed shapes (bad times, wrong types, missing windows, invalid weekdays, extra fields) do not.
Reviewed by Cursor Bugbot for commit 7208e31. Bugbot is set up for automated code reviews on this repo. Configure here.