Skip to content

chore(weave): add manual cost overrides and update costs 5/19#6889

Merged
jwlee64 merged 6 commits into
masterfrom
josiah/manual-costs
May 22, 2026
Merged

chore(weave): add manual cost overrides and update costs 5/19#6889
jwlee64 merged 6 commits into
masterfrom
josiah/manual-costs

Conversation

@jwlee64
Copy link
Copy Markdown
Contributor

@jwlee64 jwlee64 commented May 19, 2026

Description

Introduces a manual_costs.json file and a corresponding fetch_manual_costs() function to allow manually curated cost overrides for models that litellm and modelsBegin.json do not cover or cover incorrectly. Manual costs take precedence over both litellm and modelsBegin sources when merging in main().

New manual costs

  • gemini-3.1-flash-lite (via Gemini, Vertex AI, and OpenRouter)

The fetch_manual_costs() function gracefully handles missing or malformed files by returning an empty dict and printing a warning, so the pipeline continues running from litellm and modelsBegin sources.

Ran make update_costs and make update_model_providers after adding the manual costs file

Testing

Unit tests were added for fetch_manual_costs() covering:

  • Missing file returns empty dict without crashing
  • Malformed JSON is tolerated and returns empty dict
  • Well-formed entries load correctly while malformed entries are skipped
  • When a model has multiple historical entries, the most recent one is used
  • Manual costs correctly override litellm costs for the same model ID in the main() pipeline

Existing test_main tests were updated to mock fetch_manual_costs to maintain test isolation.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
weave/trace_server/costs/update_costs.py 90.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jwlee64 jwlee64 changed the title Add manual cost file, add costs from gemini 3.1 and 3.5 chore(weave): add manual cost overrides and update costs 5/19 May 19, 2026
@jwlee64 jwlee64 marked this pull request as ready for review May 19, 2026 20:08
@jwlee64 jwlee64 requested a review from a team as a code owner May 19, 2026 20:08
@wandbot-3000
Copy link
Copy Markdown

wandbot-3000 Bot commented May 19, 2026

Copy link
Copy Markdown
Member

@gtarpenning gtarpenning left a comment

Choose a reason for hiding this comment

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

what happens if both litellm reports and we manually enter? who wins? probably should be litellm?

@jwlee64
Copy link
Copy Markdown
Contributor Author

jwlee64 commented May 21, 2026

It was the manual costs, but makes sense to me to default to litellm

@jwlee64 jwlee64 enabled auto-merge (squash) May 22, 2026 17:54
@jwlee64 jwlee64 merged commit 153ccd1 into master May 22, 2026
340 of 343 checks passed
@jwlee64 jwlee64 deleted the josiah/manual-costs branch May 22, 2026 18:03
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants