Skip to content

test(batches): assert completed Vertex batch cost at batch rates - #37443

Open
harryzhou2000 wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
harryzhou2000:fix/vertex-batch-cost-test-batch-pricing
Open

test(batches): assert completed Vertex batch cost at batch rates#37443
harryzhou2000 wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
harryzhou2000:fix/vertex-batch-cost-test-batch-pricing

Conversation

@harryzhou2000

@harryzhou2000 harryzhou2000 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Completed Vertex batch cost assertion still uses non-batch rates after the model catalog added batch rates
  • test_handle_completed_vertex_batch_computes_cost_usage_and_models fails on litellm_internal_staging

How it solves it:

  • Assert the completed Vertex batch cost against input_cost_per_token_batches and output_cost_per_token_batches

User Flow

Before: the staging branch's misc CI shard fails on the completed Vertex batch cost assertion.

  1. CI runs tests/test_litellm/batches/test_batch_utils.py
  2. The test computes cost from the batch token prices (3.9375e-05)
  3. The assertion expects non-batch prices (7.875e-05) and fails

After: the assertion matches the batch prices the model catalog advertises.

  1. CI runs the same test
  2. The test computes cost from the batch token prices
  3. The assertion expects the same batch prices and passes

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

Before (8941f2a6)

  1. Run pytest -q tests/test_litellm/batches/test_batch_utils.py::test_handle_completed_vertex_batch_computes_cost_usage_and_models
  2. Observed: assert 3.9375e-05 == 7.875e-05 fails

After (daf5c7e71c)

  1. Run the same pytest command
  2. Observed: 1 passed

Type

✅ Test

QA runbook

  • tests/test_litellm/batches/test_batch_utils.py::test_handle_completed_vertex_batch_computes_cost_usage_and_models - the completed Vertex batch cost assertion now matches the batch rates in the model catalog
    • Check that vertex_ai/gemini-3.6-flash advertises input_cost_per_token_batches: 3.75e-07 and output_cost_per_token_batches: 1.875e-06 in model_prices_and_context_window.json
    • Run the pytest command above
    • Expect the test to pass
    • Sanity check: the assertion still guards cost accounting and is not weakened

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

@harryzhou2000

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects the completed Vertex batch test to assert costs using the model catalog’s batch-specific token rates.

  • Updates input pricing from 7.5e-07 to 3.75e-07 per token.
  • Updates output pricing from 3.75e-06 to 1.875e-06 per token.
  • Preserves the existing positive-cost, usage, and model assertions.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
tests/test_litellm/batches/test_batch_utils.py The revised expectation matches the canonical Vertex batch rates and continues to validate the computed cost, usage totals, and returned models.

Reviews (2): Last reviewed commit: "test(batches): assert completed Vertex b..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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