Repository navigation
test(responses): audit #47504 - #48787
Conversation
|
@litereview code-review |
[Low impact] The test-only change appears safe to merge SummaryAdds a test that checks a background response counts toward the key’s budget when a team-only model is called by its public name
Reviews (3) · Last reviewed commit: "test(responses): audit #47504" · Reviewed by Greptile |
| ) -> None: | ||
| with gateway.scenario() as scenario: | ||
| team_id: Final = scenario.team() | ||
| upstream: Final = scripted_upstream(scenario, background_routes("completed"), model_info={"team_id": team_id}) |
There was a problem hiding this comment.
Live-provider proof is missing
The claim “Every audited behavior holds at the merge commit and at this branch's tip, and each budget behavior fails at its parent” is backed only by integration tests with scripted responses. The repository requires live-provider proof for runtime claims, including test-only PRs. Before merging, show commands and outputs at this tip with a live proxy calling OpenAI through POST /v1/responses and GET /v1/responses/{id}, followed by the budget refusal
Rule Used: Apply this rule to every PR, including PRs that change only tests, docs, or catalog data. It does not require new live tests for test-only PRs; it only checks that each runtime claim the PR makes is backed by evidence at this PR's tip A runtime clai... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
These cells run a real proxy and Postgres at this tip, only the upstream is scripted, and spend attribution never depends on which provider answered
There was a problem hiding this comment.
That’s a fair distinction: a real proxy and Postgres at this tip provide meaningful evidence for the accounting path, and the upstream’s response likely does not affect spend attribution. But the review rule explicitly excludes scripted upstreams as proof for runtime claims and asks for a live proxy call to a real provider. Since the PR description makes before/after runtime claims about budget enforcement, the live-provider finding still applies under that rule—even though these cells are useful evidence for the provider-independent accounting behavior.
There was a problem hiding this comment.
Added a live OpenAI gpt-5.4-nano run at the parent and this tip. The parent keeps answering 200, and the tip refuses with exceeded budget
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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 f94e324. Configure here.
Post-merge audit of #47504, which made a background response the poller bills count toward the creating key's project and toward the key's, team's, user's, and budget tier's per-model budgets. Every audited behavior holds at the merge commit and at this branch's tip, and each budget behavior fails at its parent
This adds one integration test, for a team-only model's budget under the name the caller used, which a mutation run showed the existing cells miss. No product code changes
Original
TLDR
Problem this solves:
How it solves it:
User Flow
This PR only adds a test. The flow below is the one #47504 changed, as observed in this audit
Before (06e3e32): a developer's background responses slip past their key's per-model budget
completedAfter (d776277): the same response counts toward the project and the model budget
completedexceeded budget for model=<model>, also for a team, user, or budget tier budget and a team model called by its public nameRelevant issues
Follow-up audit of #47504
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 moreDelays 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
Audit verdict PASS. Base is #47504's parent
06e3e32c88, head is its merge commitd776277647, and the cells also ran at this branch's tipf94e324199. Every cell ran in theaccountingintegration group as CircleCI runs it, with this branch's tests laid over both commits. R2 also ran live on OpenAIgpt-5.4-nanothrough a proxy at the parent and one at the tipR1 runs in every R2 to R6 cell, and only the user cell shows it at base, since base's cost tracking filled in the project for a key with no alias and no user. R6 is the new cell, and with the merge commit's requested-model check forced off it failed while R2 passed. R7 is #47504's unit table. R9 is 5 existing cells that charged the key twice at the merge commit, the same red main's CircleCI showed until #47510 fixed it after this merge
Before (06e3e32)
Project and per-model budgets
uv run --no-sync python tests/integration/run.py accounting 'tests/integration/spend/test_background_response_billed_once.py::test_a_billed_background_response_counts_toward_its_creators_project_and_model_budget[key]' ...[team] ...[user] ...[budget_tier] 'tests/integration/spend/test_background_response_billed_once.py::test_a_billed_background_response_on_a_team_model_counts_toward_the_budget_of_the_model_name_it_was_created_with'5 collected, 0 passed, 5 failed.[user]stops at the project check with key spend0.066and project spend0.0, and the other four stop because the next background create keeps returning200 OKKey model budget, live on OpenAI
Steps
06e3e32c88withopenai/gpt-5.4-nano, Postgres, andproxy_batch_polling_interval: 1After (d776277)
Project and per-model budgets
41066025 collected, 5 passedon both runsControls
Steps
uv run --no-sync python tests/integration/run.py accountingwith the 5 billed-once cells intest_background_response_billed_once.pyandtest_completed_batch_spend_lands_under_batches_in_team_endpoint_activity,test_batch_cost_row_is_filtered_and_charged_once0.066for a0.033response, the inherited double chargeAfter (f94e324, this branch)
Project and per-model budgets
41066035 collected, 5 passedon both runs, andtests/unit/proxy/common_utils/test_check_responses_cost.pypasses 80 of 80Controls
Steps
7 collected, 7 passed, so the double charge the merge commit showed is gone hereKey model budget, live on OpenAI
Steps
f94e324199withopenai/gpt-5.4-nano, Postgres, andproxy_batch_polling_interval: 1Type
✅ Test
Caveats (if any)
Medium
Low
Final Attestation
Bugbot summary