Repository navigation
chore(backport): billing fixes for LIT-145 and aiohttp 3.14.4 onto stable/1.105.x (1.105.3) - #47714
Merged
yuneng-berri merged 29 commits intoOct 21, 2026
Conversation
…one and /v1/decisions (#47183) * fix(decisions): log every request field the caller sent on /v1/systemone and /v1/decisions * fix(decisions): serialize the logged request with model_dump_json so no mutable dict is built * refactor(decisions): drop the state-only messages pick in function_setup, prepare_call logs the request * fix(decisions): return the single logged message so no mutable list type is annotated * fix(decisions): log the caller's raw request fields before validation so a rejected request is still recorded * fix(decisions): serialize the raw request fields with pydantic_core so question objects and mapping proxies log as JSON * fix(decisions): log the caller request at the SDK entry so requests rejected before prepare_call are recorded too * test(decisions): assert the exact BadRequestError for the rejected-questions case --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47183 to stable/1.105.x. Cherry-picked from 53821f6 (main).
* feat(router): let a deployment set a timeout per service_tier Adds timeout_by_service_tier and stream_timeout_by_service_tier to a deployment's litellm_params. A request whose service_tier matches a key uses that value in place of the deployment's timeout or stream_timeout. A timeout the client sends still wins and requests without a matching tier are unchanged Co-authored-by: adc77 <amandogra2016@gmail.com> * style(router): sort the request_timeout_resolver import * fix(router): read the service tier maps without the untyped params get * fix(router): look the service tier timeout up through a typed get --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: adc77 <amandogra2016@gmail.com> Backport of #47406 to stable/1.105.x. Cherry-picked from 62ce515 (main).
…d input rate when no modality rate exists (#47373) * fix(cost): bill Gemini audio/image/video prompt tokens at the resolved input rate when no modality rate exists Co-authored-by: shivam <shivam@berri.ai> * style(cost): ruff format the modality cost calls --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: shivam <shivam@berri.ai> Backport of #47373 to stable/1.105.x. Cherry-picked from 09e9193 (main).
…1/messages (#47394) * fix(anthropic): apply tool_config cache-control points on chat and /v1/messages A cache_control_injection_points entry with location tool_config was spread into the Anthropic request body on /v1/chat/completions, which Anthropic rejected with 400 Extra inputs are not permitted, and the native /v1/messages path dropped the point silently. Both paths now put the point's control on the last tool Anthropic caches and never forward the key. Co-authored-by: Tan Nguyen <tan@pressingly.net> * refactor(anthropic): validate tool_config inputs instead of casting them Keeps the lint gates flat: the helper takes untyped tools and points and narrows them with the existing object validators, the chat transform builds the body with the marked tools instead of writing into optional_params, and the handler reads a typed view of kwargs. * fix(openai): keep tool_config cache points out of extra_body, add integration test The cache hook hands a tool_config point on for the provider step, and for providers that call through the OpenAI SDK every non-OpenAI param rides in extra_body, so OpenAI answered 400 Unrecognized request argument supplied. The new integration file drives a live proxy against scripted Anthropic, Bedrock Converse and OpenAI upstreams for /v1/chat/completions and /v1/messages. * test(integration): cover tool_config cache points on bridged /v1/messages Three new cases on /v1/messages for models without a native Anthropic messages path: OpenAI through the Responses bridge and Gemini through the chat bridge never see cache_control_injection_points in the body, and Bedrock Nova through the chat bridge gets the cachePoint on toolConfig --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Tan Nguyen <tan@pressingly.net> Backport of #47394 to stable/1.105.x. Cherry-picked from 93b79d2 (main).
…leCharacterCount (#47460) Vertex text embedding predict responses report metadata.billableCharacterCount, the unit Google bills text-embedding-005 and text-multilingual-embedding-002 on. Carry it into usage.prompt_tokens_details.character_count and, when the model carries input_cost_per_character, bill that count instead of the token count so the prompt is charged under one unit. Per-token embeddings (gemini-embedding-001) are unchanged. Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47460 to stable/1.105.x. Cherry-picked from d29200f (main).
…#47466) * fix(batches): apply the Vertex regional endpoint uplift to batch cost batch_cost_calculator takes vertex_location and multiplies by the model's regional_endpoint_uplift_multiplier through get_vertex_regional_endpoint_uplift, and every batch cost path (aretrieve_batch pricing, completed-batch logging, native Vertex batch rows, the proxy batch cost poll and its per-line items) resolves the deployment's location and passes it down Co-authored-by: Mrun25 <165297479+Mrun25@users.noreply.github.com> * test(logging): point the resolver tests at resolve_vertex_location_for_cost --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Mrun25 <165297479+Mrun25@users.noreply.github.com> Backport of #47466 to stable/1.105.x. Cherry-picked from c6c303a (main).
…99) request's spend row (#47436) * fix(proxy): price the estimated input tokens on a client-cancelled (499) request's spend row * fix(proxy): read the provider handoff before the proxy-only error handler stamps it so a pre-handoff 499 is not priced * fix(proxy): drop the pre-logging handoff read now that pre_call no longer stamps proxy-only failures --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47436 to stable/1.105.x. Cherry-picked from 0e7c490 (main).
…U spillover (#47567) get_standard_logging_object_payload decided custom_pricing from litellm_params alone, so on an Azure PTU spillover response model_map_information kept the deployment's zeroed PTU entry while response_cost already used the standard model rate. Reuse the billing side LitellmLogging._custom_pricing_for so both read the same decision Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47567 to stable/1.105.x. Cherry-picked from 4222523 (main).
…s to the downstream proxy (#47570) PR #47394 withheld cache_control_injection_points from the OpenAI SDK extra_body for every provider on that path, which also covers litellm_proxy. The downstream LiteLLM proxy applies the point itself, so litellm_proxy keeps forwarding it while OpenAI and the other OpenAI-compatible providers still never receive it Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47570 to stable/1.105.x. Cherry-picked from 04e9ed4 (main).
…he failed request (#47490) * feat(proxy): lift every earlier billed timed-out retry attempt onto the failed request _billed_earlier_attempts reads the router's previous_models records, keeps the Timeout ones other than the final attempt (matched on deployment_id plus attempted_retries, since the count restarts after a fallback hop and the fallback handler re-logs the exhausting attempt) and prices each at the deployment that served it. post_call_failure_hook lifts the tuple as billed_failed_attempts; nothing writes it yet. previous_models joins the router-reserved metadata fields so a client-planted record never reaches it * fix(proxy): price earlier timed-out attempts from the prompt estimate only The final row may lift a mid-stream recovered usage (prompt plus delivered chunks) or a failed_attempts_usage sum; earlier attempts never produced output, so they are priced from _estimated_prompt_usage, and when failed_attempts_usage already bills them into the final row none is lifted again --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47490 to stable/1.105.x. Cherry-picked from 7a4a255 (main).
…47416) _failure_spend_rows yields the final row plus one re-keyed row per lifted billed_failed_attempts entry (<request_id>-attempt-<position>, the attempt's usage, cost, retry count and deployment id), each written through DBSpendUpdateWriter.update_database so it also deducts from key, team and user spend Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47416 to stable/1.105.x. Cherry-picked from ad8ca53 (main).
…pend (#47494) * feat(proxy): opt-in free-tier allowance for Google Search grounding spend * fix(proxy): declare the search free tier counter's service target * test(cost_map): allow search_free_requests in the cost map schema * fix(proxy): skip cache hits and never free more than the billed cost in the search free tier --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47494 to stable/1.105.x. Cherry-picked from e63aec0 (main).
…idge reads back (#47614) Every /v1/responses spend log asked its worker to flush the queue right away so a chained previous_response_id could find the row. Only the chat-completions bridge reads that row. Native Responses providers hold the conversation upstream, so their rows now wait for the batch write like chat rows do Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47614 to stable/1.105.x. Cherry-picked from 423362b (main).
…nects (#47611) * fix(proxy): bill partial Responses API streams when the client disconnects Streamed /v1/responses requests and the default-route OpenAI and Azure /v1/messages requests behind them logged a 499 with zero spend when the client went away mid-stream, while /v1/chat/completions already billed the chunks it had sent. The Responses API iterator now keeps the response.created payload and can hand the disconnect cleanup a response.incomplete event with counted usage and the served service_tier, and the messages-route byte stream and router wrappers delegate to it. * fix(proxy): satisfy lint gates for partial Responses API disconnect billing Make the disconnect helper public so the proxy, router and messages adapter can import it without reportPrivateUsage, type the SSE byte stream as an AsyncGenerator so aclose is known, read litellm_call_id off the logging object, and keep the new tests on Final locals with the recorder injected through dynamic_async_success_callbacks instead of litellm.callbacks. * fix(router): bill the primary stream's tokens after a mid-stream hop and chat-bridge Responses streams on disconnect The router's fallback wrapper now folds the primary Responses stream's relayed tokens into the fallback's disconnect event the way _combine_responses_fallback_usage does for a natural end of stream, and LiteLLMCompletionStreamingIterator (chat-only providers served through /v1/responses) builds its disconnect event from the chat completion chunks it collected. stamp_responses_usage_cost is now public so the bridge module can price that event. * Potential fix for pull request finding 'CodeQL / Log Injection' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Backport of #47611 to stable/1.105.x. Cherry-picked from f0ae445 (main).
…e surrogates in multipart metadata (#47639) * fix(proxy): strip caller base_model from spend pricing and reject lone surrogates in multipart metadata * fix(proxy): type the parsed multipart metadata so basedpyright does not grow reportArgumentType --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47639 to stable/1.105.x. Cherry-picked from 2a26895 (main).
…der (#47646) * fix(proxy): scope the search free-tier counter to the request's provider * fix(proxy): read the provider with get so partial spend payloads still get the free tier * test(proxy): give the grounded spend payload fixture its provider --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47646 to stable/1.105.x. Cherry-picked from 640f2d8 (main).
…, and never after the call already completed (#47652) * fix(proxy): price a 499 spend row only for the proxy's own disconnect, and never after the call already completed * fix(proxy): gate the zero-cost 499 row on the success log being enqueued, not merely claimed --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47652 to stable/1.105.x. Cherry-picked from ffb7133 (main).
…47617) * fix(router): price cost-based routing through model_info.base_model * fix(router): keep cost-based routing pricing helpers fully typed * fix(router): drop typing.cast from cost-based routing pricing helpers * fix(router): read the cost map through a typed accessor in cost-based routing * fix(router): avoid a Final rebind inside the cost-based routing loop * refactor(router): share deployment_pricing_models across spend, listing and cost-based routing * refactor(router): keep the /v1/models listing key inline, share pricing models for spend and routing * refactor(router): inline the deployment pricing-model wrapper in cost-based routing * refactor(router): read deployment pricing models through one shared helper deployment_pricing_models(deployment) now owns the model_info.base_model / litellm_params.base_model / litellm_params.model unpacking, used by cost-based routing and the /v1/models listing. pricing_models(base_model, model) stays for the failure-row spend estimate, which already holds the two names * refactor(router): share the str-keyed mapping validator with cost-based routing * ci: re-run after flaky test_aiohttp_transport read timeout in llms-providers --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47617 to stable/1.105.x. Cherry-picked from 0c6731e (main).
…yment's model rate (#47648) * fix(proxy): bill every earlier timed-out retry attempt at its own deployment's model rate * fix(router): read the retry record's base_model through the typed metadata helper * fix(router): keep the four-record retry breadcrumb cap * fix(router): carry a deployment's litellm_params base_model on its retry record * chore(router): place the cast-ok reason on the cast line and list the base_model helper as covered through log_retry --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47648 to stable/1.105.x. Cherry-picked from 27efc38 (main).
…rved model's rates (#47655) * fix(logging): report pay-as-you-go rates for spilled over PTU requests without base_model * fix(logging): keep the provider response model so spilled over PTU payloads price the served model * fix(logging): keep a provider_response_model the response already carries * fix(logging): read the carried provider_response_model through a typed adapter --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of #47655 to stable/1.105.x. Cherry-picked from 6b1f4ed (main).
Lock-only bump for GHSA-2g87-pp6c-29x5, GHSA-5wr8-gcqf-gqf3 and GHSA-494j-54xm-rwp3 (aiohttp 3.14.3 -> 3.14.4, yarl 1.23.0 -> 1.25.1 moves with its new floor). main is on 3.14.5. pyproject constraint aiohttp>=3.14.2,<4.0 is unchanged.
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
yuneng-berri
had a problem deploying
to
e2e-changed
October 21, 2026 07:50 — with
GitHub Actions
Error
yuneng-berri
approved these changes
Oct 21, 2026
yuneng-berri
had a problem deploying
to
e2e-changed
October 21, 2026 08:02 — with
GitHub Actions
Error
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
How it solves it:
Linear ticket
Resolves LIT-145
Picks
Source PRs in the order they were applied, each a single commit carrying its main squash sha in the body
Empty pick: #47565 is not applicable to this line. It fixes
_tool_carries_ephemeral_mark, a helper #46411 added on main only; the line'sprompt_caching_cache.pyhas no tool cache_control helpers and notests/unit/router_utils/test_prompt_caching_cache.pyAdaptations to the line
Each pick keeps main's behavior and only swaps in the names this line has
/v1/decisionsand/v1/systemonesignatures are kept, the request-field logging helpers are added around them_get_service_tier_cost_keyis kept; the maincases/vertex_ai.pycase was translated intocost_tracking_cases.json, where this line keeps its casesOBJECT_LIST_ADAPTERandvalidated_object_listadded next to the line's existing mapping adapter;tests/integration/providers/test_tool_config_cache_point_wire.pydropped (needs the main-onlytests/integration/_support/openai_wire.py)tests/unit/router_utils/test_request_timeout_resolver.pystyle file, so its tests live intests/local_testing/test_router_timeout.py_get_base_model_from_metadataand_response_cost_calculator(public names come from main-only refactor: expose core private helpers under public names #44871), imported with areportPrivateUsageignore;get_standard_logging_object_payloadimport added totests/unit/litellm_core_utils/test_litellm_logging.py;test_response_metadata.pycalls the line's_select_model_name_for_cost_calctest_vertex_embedding_usage_carries_the_billable_character_count_google_prices_ondropped (its filetests/unit/llms/vertex_ai/vertex_embeddings/test_embedding_handler.pyis main-only, added by chore(typing): clear 670 basedpyright Any errors by validating provider payloads at the boundary #45388); the unit cost-calc test is keptlitellm/batches/batch_line_items.pyandtests/unit/batches/test_batch_line_items.pyhunks dropped (module is main-only, feat(batches): store each batch line's request and response in S3 and GCS #41691); the Vertex location is threaded through the line's single_handle_completed_batchpoll path, and the picked tests call that name;tests/unit/test_cost_calculator.pyimportsbatch_cost_calculatorat module leveltest_attempts_already_summed_into_the_final_row_are_not_lifted_againdropped (assertsLogging.carry_failed_attempt_usagefrom main-only fix(responses): log and bill every round of non-stream MCP auto-execute #43667); main-only session metadata test content not pulled in_failure_snapshot_with_guardrails_recorded_after_itis main-only), so_failure_spend_rowsreceives None andend_user_idstays the line'suser_api_key_dict.end_user_id; its test uses the line's_ProxyDBLoggersearch_free_requestsadded to the same 47 cost-map rows by textual insertion;_str_keyed_fieldsplus a local_is_str_keyed_mappingguard added toproxy_track_cost_callback.py; the main-onlywith_service_targetdecorator dropped fromsearch_free_tier.py; carries chore(cost-map): add search_free_requests to the model prices schema #47635'ssearch_free_requestsentry inci_cd/generate_model_prices_schema.pyand the regeneratedmodel_prices_and_context_window.schema.jsonso the line'stest_model_prices_schemastays greenaudioandvideoskwargs of_prepare_decisions_call_provider_stores_the_first_round, soprovider_stores_the_conversationis a new helper over the line's_will_bridge_to_chat_completions; the main-only_responses_routertest helper was copied into the line'stest_db_spend_update_writer.py; main-only lock-timeout tests not pulled inAnthropicResponsesSSEByteStream;sanitize_for_logis main-only, the disconnect debug log uses the line's own call-id formattingtest_http_parsing_utils.pykeeps the line's_read_request_bodyname and skips the main-only OTLP 410 test and fixtures_estimated_input_costtaken as main has it, including the base_model-then-model candidate orderLogging.__init__keeps the line's_on_detached_stream_failureand gains only_async_success_enqueued(no_sync_success_scheduled)test_lowest_cost.pykeeps the line's short file (main-only test: move the unit half of 126 mixed legacy files into tests/unit #45090 fixtures not pulled in), new base_model test appendedtests/router_unit_tests/test_router_helper_utils.pyon this line, added without the main-onlyrouter_minute_pinnedfixture;router.log_retryimports the line's private_get_base_model_from_litellm_call_metadataVerification
Picked tests: every changed test file was run with the line's own venv (
uv sync --frozen --extra proxy --group dev --group proxy-dev --group ci). All pass except two pre-existing environment failures that fail identically on thestable/1.105.xbase:TestPrismaClientTokenAuthBehindThePool(needsprisma generate) andtest_router_timeouts(needsREDIS_PORT)Identifier checks:
ruff check --select F821over every changed file is clean,basedpyright --level errorover the changed files reports zeroreportUndefinedVariable, and every changedlitellm/module imports in the line's venvGrype on
uv.lock: aiohttp 3.14.3 had fixes at 3.14.4 (main is on 3.14.5), bumped lock-only withuvx uv@0.11.7 lock --upgrade-package aiohttp==3.14.4, which moves yarl to 1.25.1. Still reported, no lock-only fix available on this line: claude-agent-sdk 0.1.44 GHSA-h4mw-j7qp-8mwm (Critical, fix is 0.2.121 butpyproject.tomlpins==0.1.44), mlflow 3.15.0 GHSA-h7x2-h6g9-p789 (High, no fixed version listed), diskcache 5.6.3 GHSA-w8v5-vhqr-4h9v (Medium, no fix, main has it too)Integration and e2e runs on the line venv, base of
stable/1.105.xvs this branch where a failure needed classifying.tests/integrationgroups through a hand-started rig mirroring.circleci/scripts/run_integration.sh(scripted upstream on 8190, proxy on 4000, fresh Postgres 14 db per group, local Redis):cost483 passed, 2 failed, both the claude-sonnet-5 stream_no_usage recount pins (48 vs pinned 47, 303 vs 301) and both fail the same way on the base, main already pins 48 and 303;database35 passed;accounting285 passed, 18 failed, 2 errors, of which 16 failures and both errors areKeyError: general_settingsorlitellm_settingsbecause the line'stests/integration/proxy_config.yamlcarries only amodel_list, and the other two (test_cache_and_quota) fail identically on the base;providers446 passed, 65 failed, 20 errors, all of them missinggoogle.genaiin the venv, the same truncated proxy config, thebedrock_runtime_peercollection error, or files that fail with the same counts on the base (test_decisions_wire,test_decisions_openai_format_wire,test_responses_bridge_stream_options: 6 failed 69 passed on both; the anthropic reasoning wire file: 1 failed 47 passed on both).tests/e2eagainst a live proxy on this branch with real OpenAI, Anthropic and Gemini:llm_translation(chat, stream, messages, responses, bridge streaming, custom pricing, cache control, embeddings, tool round trip) 58 passed, 3 failed, all three needing Azure or Cohere deployments the rig has no credentials for;quota_management/budgets42 passed, 1 failed (test_cold_counter_reseedopens aRedisCluster, the rig runs a standalone Redis, same failure on the base);router31 passed, 3 failed, 1 error, all Azure deployment, idle RSS budget or a model-create race in the rig. None of these failures are new on this PR: every one either fails identically on the base ofstable/1.105.x(fc43640) or comes from the local rig (missing credentials, standalone Redis, missinggoogle.genai, the line's truncated integration proxy config)Gauntlet-mini relay
Run in degraded mode (no Agent tool in this session): the five lenses were run by hand against
/tmp/wt_stable_1_105_xwith basegit merge-base origin/stable/1.105.x HEADand the diff at/tmp/gm-diff-stable_1_105_x.patch, so this is slower and weaker than the fan-outHeadline: SURVIVED. Sub-claims: changed identifiers resolve (ruff F821, basedpyright undefined-variable, importer scan: all clean); picked tests pass against the line's own baseline (all green, two baseline-only environment failures listed above); callers on the line of the modified functions still work (
tests/unit/proxy/hooks943,tests/unit/responses880,tests/unit/llms/anthropic2158,tests/unit/router_utils811,tests/unit/proxy/common_utils1160,tests/unit/batches215,tests/unit/decisions87,tests/unit/litellm_core_utils/llm_cost_calc323,tests/unit/proxy/db1150 passed with the same 22 prisma-generate failures as the base); bumped deps behave (aiohttp 3.14.4 and yarl 1.25.1 import,tests/unit/llms/custom_httpx356 passed); blackbox smoke oflitellm.completion,Router.acompletionwithbase_model, a routed timeout andproxy_server.appimport all succeedConfirmed findings: none. Strongest dissent: the four picked tests that called main-only public names (
handle_completed_batch,ProxyDBLogger,select_model_name_for_cost_calc,response_cost_calculator) failed on the first run and were rewritten to the line's private names inside their pick commits; the dropped #47490 test was the only one asserting main-only behavior. Per-lens: correctness 0 confirmed, dependents 0, blackbox 0, contract 0 (basedpyright rule histogram on the changed files moved only in the Unknown*/Any budget rules), conventions 0 (the added comments are the source PRs' own). Coverage notes: the live proxy leg on this line is in Screenshots / Proof of Fix (run after the relay), no gauntlet ledger row writtenPre-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 more@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Live leg on this line, no mocks: two proxies started from the line's venv with
python litellm/proxy/proxy_cli.py --config <cfg> --port <port> --use_v2_migration_resolver, base =origin/stable/1.105.xworktree on port 4100 with Postgres 14 dblitellm_105_base, tip = this branch on port 4200 with dblitellm_105_tip, real OpenAI (openai/gpt-5.4-mini, $0.75/M input, $4.50/M output in the line's cost map),prisma generaterun first. Same config on both legs apart fromdatabase_url:Result: the base timeout row has 24 prompt tokens and spend 0, the tip timeout row has the same 24 prompt tokens priced at 24 x $0.75/M = 1.8e-05 (#47435). The fast-mini row prices identically on both legs: 12 x $0.75/M + 8 x $4.50/M = 4.5e-05
Before (fc43640, base of stable/1.105.x)
slow-mini hits the 1s timeout and gets a 408
curl -s -o /dev/null -w "%{http_code}\n" localhost:4100/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"slow-mini","user":"lit145-base-timeout","messages":[{"role":"user","content":"Write a 3000 word essay on the history of the Roman aqueducts."}]}'408(body:litellm.Timeout: APITimeoutError - Request timed out ... timeout value=1.0)fast-mini succeeds
curl -s localhost:4100/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"fast-mini","user":"lit145-base-ok","messages":[{"role":"user","content":"Say hi in three words."}]}' | jq -c "{content: .choices[0].message.content, usage}"{"content":"Hi there, friend.","usage":{"completion_tokens":8,"prompt_tokens":12,"total_tokens":20,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0}}}spend rows after ~10s
psql -d litellm_105_base -c "select end_user, status, prompt_tokens, completion_tokens, spend from \"LiteLLM_SpendLogs\" where end_user like 'lit145-%' order by \"startTime\""After (1509e15)
slow-mini hits the 1s timeout and gets a 408
curl -s -o /dev/null -w "%{http_code}\n" localhost:4200/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"slow-mini","user":"lit145-tip-timeout","messages":[{"role":"user","content":"Write a 3000 word essay on the history of the Roman aqueducts."}]}'408(body:litellm.Timeout: APITimeoutError - Request timed out ... timeout value=1.0)fast-mini succeeds
curl -s localhost:4200/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"fast-mini","user":"lit145-tip-ok","messages":[{"role":"user","content":"Say hi in three words."}]}' | jq -c "{content: .choices[0].message.content, usage}"{"content":"Hi there, friend.","usage":{"completion_tokens":8,"prompt_tokens":12,"total_tokens":20,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0}}}spend rows after ~10s
psql -d litellm_105_tip -c "select end_user, status, prompt_tokens, completion_tokens, spend from \"LiteLLM_SpendLogs\" where end_user like 'lit145-%' order by \"startTime\""Source PR proofs replayed on the line
Each source PR's "Screenshots / Proof of Fix" was replayed against the base of stable/1.105.x (fc43640, port 41xx) and this PR's tip (1509e15, port 42xx), both from the line venv, each with its own Postgres 14 database, real OpenAI, Anthropic, Gemini and Vertex AI where the source used them and a local scripted upstream where the source used one. Rows were read with psql. Where the line's base already differs from the source PR's merge base the base column says so instead of forcing the source's Before
Not replayed: #47466 (Vertex batch regional uplift) needs a GCS bucket for the batch input file and this rig has none, #47614 (Responses turn spend-log flush) needs the perf lane gateway with Postgres 17 pg_stat_statements and its mock provider servers, and #47456 has no curl-visible seam (the source proof is the hook-level unit test, which ran in the picked tests)
Known metadata caveat on #47494 and #47646: on the tip every grounded row's
spendand the Redis counter are right, but in 6 of 10 rowsmetadata.cost_breakdown.discount_amountis 0.0 andtotal_costis the pre-allowance value (a proxy from origin/main 3985795 was 7 of 7 consistent). The line does not have #47019 (fix(logging): keep the async request's logging payload when the sync success thread runs late), so the sync success thread can rebuildstandard_logging_objectwhile the free-tier hook awaits Redis and the row is built from the rebuilt payload. #47019 does not cherry-pick cleanly onto this line (conflicts in litellm_logging.py and caching_handler.py) and is not picked here, that is a separate decisionGroup A, OpenAI timeout / disconnect / retry / partial stream billing (#47435 #47437 #47436 #47416 #47490 #47648 #47652 #47611 #47639), config /tmp/grpA_1105/config.yaml, real OpenAI
base
tip
Group B, Anthropic cache_control_injection_points (#47394 #47570), real Anthropic
base
tip
Group C, Gemini and Vertex (#47460 #47647 #47494 #47646), real Gemini API and Vertex AI
base
tip
base, #47460 rerun without the user param
tip, #47460 rerun
base, #47647 rerun with a 1.75M char prompt
tip, #47647 rerun
tip, #47494 breakdown probe, 6 calls
main 3985795, #47494 breakdown probe, 6 calls
Group D, scripted upstreams (#47406 #47567 #47655 #47183 #47564 #47617), fake upstream /tmp/grpD_1105/fake_upstream.py
base
tip
base, #47183 rerun
tip, #47183 rerun
base, #47567 #47655 rerun with unique upstream ids
tip, #47567 #47655 rerun
Type
🆕 New Feature
🐛 Bug Fix
Caveats (if any)
Medium
Low
tests/unit/proxy/dband the Prisma token tests needprisma generatelocallyFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/fc365d3ce825449f9eb0fcaac0ddde69
Open in Devin Desktop: https://app.devin.ai/desktop/session/fc365d3ce825449f9eb0fcaac0ddde69?variant=devin
Requested by: @kerrylu-berri