Repository navigation
fix(logging): price terminal Responses stream events from their inner response - #42385
Conversation
… in post-success hooks Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…o bytes without auth Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… response Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
| store_model_in_db: true | ||
| disable_spend_logs: false | ||
| proxy_batch_write_at: 1 | ||
| allow_unmanaged_response_ids: true |
There was a problem hiding this comment.
Shared config bypass Enabling this here disables default unmanaged-ID rejection across shared-config integration tests, reducing full-proxy coverage. Scope it to the affected fixture.
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.
This is a proxy-wide general_settings flag, not scopable per test. No shared-config integration test exercises unmanaged-id rejection, so coverage is unchanged.
There was a problem hiding this comment.
You're right. allow_unmanaged_response_ids is a proxy-wide setting in this integration configuration, so it cannot be scoped to a single test. Since the shared integration suite does not exercise unmanaged-ID rejection, enabling it here does not reduce existing coverage. This comment does not apply.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance
Comparing Footnotes
|
|
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 2f6a9eb. Configure here.
TLDR
Problem this solves:
integration-costred on main: 23 cases,integration-providersred: 1 caseHow it solves it:
response.completedetc) and prices the inner responseallow_unmanaged_response_idsfor theprevious_response_idcaseUser Flow
Before: a developer streams a Responses call and the spend log shows the right total but a zero cost breakdown
"model": "gpt-5.6", "stream": trueresponse.completedevent carryingusagewith 1840 input and 412 output tokensAfter: the same request stores a breakdown that matches the spend
"model": "gpt-5.6", "stream": trueresponse.completedeventChat completions routed through the Responses bridge (
gpt-5.x-codex,-pro) hit the same path and are fixed the same way.Relevant issues
The two fixture fixes have no product-facing change: the
previous_response_idcase sends an id the proxy never issued, which the proxy rejects with 403 by design since #39548, and the fal.ai H3 fake upstream required the fal auth header on the bare mp4 download.Affected release
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Run with the canonical CircleCI runner (
.circleci/scripts/run_integration.sh) against a live proxy, Postgres, Redis and the scripted upstream on this machine. No real provider calls: the cost suite is a pricing contract and pins exact spend, so a scripted upstream is the correct oracle.Before (275c0c4, merge base)
integration cost
bash .circleci/scripts/run_integration.sh cost23 failed, 460 passed, e.g.gpt-5.5-pro-stream_no_usage: row spend 0.00216 != breakdown total_cost 0.0andgpt-5.6-responses_previous_response_id: proxy returned 403 ... allow_unmanaged_response_idsintegration providers
bash .circleci/scripts/run_integration.sh providers1 failed, 22 passed:test_fal_h3_video_create_uses_canonical_body_and_status_path, content download returns 500 (KeyError: 'authorization'in the fake upstream)unit
pytest tests/test_litellm/litellm_core_utils/test_litellm_logging.py -k terminal_responses_eventFAILED ... assert (0.0 is not None and 0.0 > 0)After (3ae43d3)
integration cost
bash .circleci/scripts/run_integration.sh cost483 passed in 124.40sintegration providers
bash .circleci/scripts/run_integration.sh providers23 passed in 75.61s(plus4 passedreplay controls)unit
pytest tests/test_litellm/litellm_core_utils/test_litellm_logging.py tests/test_litellm/responses/test_streaming_iterator.py340 passedSame 24 failures were red on CircleCI main (pipeline 90023, jobs 2198864 and 2198859), so this should turn the
integrationworkflow green.Type
🐛 Bug Fix
✅ Test
Caveats (if any)
Low
Final Attestation
Link to Devin session: https://app.devin.ai/sessions/bb25954394a4480d83a4fae2a50cb954
Open in Devin Desktop: https://app.devin.ai/desktop/session/bb25954394a4480d83a4fae2a50cb954?variant=devin
Note
Low Risk
Logging/pricing path change with targeted tests; spend totals were already correct and integration config changes are test-only.
Overview
Fixes zero cost breakdown on streamed
/v1/responses(and related bridges) when spend was already correct:_response_cost_calculatornow unwraps terminal stream events (response.completed/ incomplete / failed) and runs pricing, hidden-params, andresponse_objectlogic on the innerResponsesAPIResponseinstead of the event wrapper.Integration-only adjustments: proxy test config sets
allow_unmanaged_response_idssoprevious_response_idcases are not rejected with 403, and the fal.ai H3 wire mock serves mp4 GET before enforcing the auth header (matching Seedance). A unit test asserts event cost equals inner-response cost and populatescost_breakdown.Reviewed by Cursor Bugbot for commit 2f6a9eb. Bugbot is set up for automated code reviews on this repo. Configure here.