Repository navigation
fix(cost): price exact cost-map names before capability-only Claude rules, and fix SCIM and MCP integration tests on CircleCI - #46763
mateo-berri wants to merge 15 commits into
Conversation
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)".
|
|
@litereview code-review |
|
bugbot run |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…and keep the unpriceable case unmapped Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
|
@litellm-stampbot |
litellm-stampbot: risk highNot approved at Rules (
Judge (gpt-6-luna): high, probability of high 1.00 (high at or above 0.75)
Pushes do not re-run this check. Comment |
…_bedrock_cost_scim
…43043 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@litereview code-review |
| for candidate, is_generalized in zip(raw_candidate_names, candidate_is_generalized, strict=True) | ||
| if is_generalized | ||
| ) | ||
| potential_model_names: Final = (*exact_model_names, *generalized_model_names) |
There was a problem hiding this comment.
High · Claude base_model on an OpenAI-compatible deployment now fails to price
- An admin configures an
openai/my-deploy(orhosted_vllm/...) deployment withbase_model: claude-sonnet-4-5. Theopenaiprovider has no row for that id. - A completion returns usage.
_base_model_pricing_providerresolvesanthropic, andselected_modelbecomesanthropic/claude-sonnet-4-5. completion_costruns that name through_cost_map_model_info(candidate, "openai"). The lookup hits theclaude-family-baselinerule under keyopenai/anthropic/claude-sonnet-4-5, sois_generalized_model_inforeturns True. The new ordering moves the base-model candidate behindmy-deployandopenai/my-deploy.- When the loop reaches the base model,
idxis no longer 0. Thepricing_provider = base_model_provider if ... idx == 0branch falls back toopenai, andcost_per_tokenraisesThis model isn't mapped yet. model=claude-sonnet-4-5, custom_llm_provider=openai. Before this PR, the same call billed0.018for 1000 input and 1000 output tokens.
The smallest fix: classify the base-model candidate under base_model_provider, or keep it first when base_model_provider is set. Alternatively, pick the pricing provider from the candidate's identity rather than its index.
Evidence
Reproducer (LITELLM_LOCAL_MODEL_COST_MAP=True): completion_cost(completion_response=ModelResponse(model="my-deploy", choices=[], usage=Usage(prompt_tokens=1000, completion_tokens=1000, total_tokens=2000)), model="openai/my-deploy", custom_llm_provider="openai", base_model="claude-sonnet-4-5")
PR head: ERR This model isn't mapped yet. model=claude-sonnet-4-5, custom_llm_provider=openai. The same error occurs with hosted_vllm.
With the pre-PR candidate list restored locally: returns 0.018000000000000002 for both providers.
Debug print at head: raw=('anthropic/claude-sonnet-4-5','my-deploy','openai/my-deploy') generalized=(True, False, False) ordered=('my-deploy','openai/my-deploy','anthropic/claude-sonnet-4-5') base_model_provider=anthropic
litellm/cost_calculator.py pricing-provider selection: base_model_provider if base_model_provider is not None and idx == 0 else custom_llm_provider
Latest summary by code-review · View this review · Reviewed 4b3ab8ede6a3
…candidate reordering Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@litereview code-review |
|
bugbot run |
|
@litellm-stampbot |
[High impact] The PR appears safe to merge with no new actionable issues found SummaryThe PR fixes cost lookup order so price-free capability rules do not hide priced model names. Priced rules and explicit pricing keep their existing behavior It also aligns Bedrock cache pins with the request’s TTL support and repairs integration fixtures, worker setup, and expected response fields. No new actionable issues were found
Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
…_bedrock_cost_scim
…onfigs 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>
|
@litereview code-review |
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@litereview code-review |
|
bugbot run |
|
@litellm-stampbot |
…_bedrock_cost_scim
…-worker allocator Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…r ttl its base model sends Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
…_bedrock_cost_scim
|
@litereview code-review |
|
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 2643fff. Configure here.
|
@litellm-stampbot |
|
Replaced by #47037, which carries every commit here as cherry-picks on top of a stampbot-approved test-only slice |
Pull request was closed
TLDR
Problem this solves:
integration-mcpproxies with a custom auth module die at boot on CircleCIserversfieldintegration-accountingpins daily activity metrics without the newptu_hoursfieldintegration-providerscannot collect the Nova Sonic realtime tests because their peer imports a removed_free_portbase_modelsends a one-hour cache TTL but the router pins the prefix for five minutesHow it solves it:
serversandptu_hours, still exactallocate_portbedrock_capability_modelandbedrock_cache_point_ttl_supportedthe wire usesUser Flow
Before: a proxy admin whose cost map prices a Bedrock model only under its route name sees the request logged at $0
bedrock/invoke/anthropic.claude-haiku-4-5-20251001-v1:0and the cost map prices that route namex-litellm-response-costheaderAfter: the same request is billed at the route's price
x-litellm-response-costat the route's ratesCircleCI context
Red on
mainin the scheduled integration workflow of pipeline 91272 at54ff82dd14, and also in pipeline 91270integration-cost fails
tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[bedrock-converse-apac-bare-fallback]and[bedrock-invoke-haiku-json]withx-litellm-response-cost None. Culprit is c3da442 (#46708), which made the scripted cost map serve the productionclaude-family-baselinecapability rule.completion_costtries the response-derived name first, that name matches only the price-free rule, so it bills $0 and never tries the priced route name. The same shadowing happens in production for any route-priced Bedrock id whose bare id is unmapped. The fix orders cost candidates so exact cost-map names come before rule-only matches, keeping the existing order inside each groupintegration-management and integration-management-replica fail
tests/integration/management/test_scim_group_bulk_roster.py::test_a_worker_killed_mid_push_leaves_the_old_roster_and_a_retry_lands_the_new_onewithValueError: not enough values to unpack. The test came in with 622daf3 (#45197) and matched Postgresclient_portagainst host sockets of the workers. Postgres runs in Docker on CircleCI, so the port it sees is NAT'd and never belongs to a worker. The test now waits for a session blocked on the held row lock and kills every serving worker, so the one holding the push's transaction is always killed and every roster assertion stays as strictintegration-accounting fails
tests/integration/spend/test_daily_rollup_retry.py::test_failed_daily_user_rollup_commit_is_retried_so_spend_report_and_daily_activity_agreeon main pipelines 91272 and 91275 withLeft contains 1 more item: {'ptu_hours': 0.0}. Culprit is e344dbd (#43043), which intentionally addedptu_hoursto daily activity SpendMetrics. The test's exact metrics dict now expectsptu_hoursat 0.0 and stays otherwise strictintegration-mcp fails 53 tests on main 91293, 91291 and 91290. 50 of them, every
tests/integration/mcp/test_interactions.py::test_modern_subscription_delivers_changes_between_calls_and_refreshes_tools[*]and::test_continuation_reauthenticates_caller_and_rechecks_revoked_permissions[*], fail withOwned proxy exited before readiness. The proxy log showsImportError: Could not import authenticate from subscription_auth. WithINTEGRATION_WORKER_ISOLATION=1,worker_configuration(from 3090f4b, #45863) rewrites the config into a temp dir, but the custom auth module the test writes beside the config stays behind, and the loader only looks next to the config. The modern subscription cases came in with 4a4a0e8 (#46153). Isolated configs now go in their own directory with the sibling.pymodules copied and their.jsonstate files linkedtest_mcp_oauth_flows.py::test_per_server_resource_scopes_the_session_bearer_to_the_named_serverand::test_spec_client_discovers_the_aggregate_authorization_server_and_signs_in_to_a_session_bearerfail with an extra'servers': None. Culprit is 1ddaa54 (#44957), which intentionally addedserversto the connect-flow description. The expected dicts add it and stay exactGreptile review on e0fe962: a capability rule that carries prices is no longer demoted behind exact names, and
custom_pricingorbase_modelcalls skip the up-front cost-map lookups and keep the original candidate orderPR branch pipeline 91297 at the tip b2c054f (workflow, rerun of failed jobs).
integration-cost,integration-accounting,integration-management,integration-management-replicaande2e_ui_testingpassed on the first run.integration-mcpwent from 53 failures on main to the one deferred test below.integration-sdkandintegration-extensionsfailed one test each on the first run and passed on the rerun,test_sdk_native_messages_stream_delivers_one_success_callback_with_usageis also red on main 91294. Earlier PR pipelines were 91276, 91277, 91286, 91287, 91295 and 91296integration-providers on main 91291, 91293 and 91294 fails to collect
tests/integration/providers/test_bedrock_nova_sonic_realtime_tool_calls.pywithImportError: cannot import name '_free_port' from 'integration._support.process'. b602209 (#46761) replaced every_free_portwithintegration._support.ports.allocate_port, then bd60cc8 (#46214) landed a peer that still imports it. The peer now usesallocate_port. Once collected, the tool-call case also expects theresponse.function_call_arguments.deltaevent #46214 intentionally emits before.doneThe same job fails
tests/integration/routing/test_prompt_cache_pin_ttl.py::test_provider_family_pin_lifetime_agrees_with_the_ttl_the_wire_carries[pin-bedrock-arn-base]on 5 of the last 6 main runs. 6c78089 (#46569) made Bedrock capability checks on application inference profile ARNs followbase_model, so the wire carriesttl: "1h", but the pin from e136e91 (#46084) still checked the ARN and pinned for 300 seconds._honors_one_hour_cache_ttlnow resolves the capability model from the deploymentmodelandbase_model, and the case expects a one-hour pin and wire TTLPR branch pipeline 91301 ran at c714d01. The tip 2643fff merges current
mainwith no conflicts and runs in PR branch pipeline 91309. There every claimed job passed, and the remaining reds are the deferred ones plustest_bridged_request_bills_the_same_row_as_the_native_request[gpt-5.6-responses_reasoning-messages_bridged]in integration-cost, which also fails on main 3 of 3 when run alone because the messages bridge sometimes drops reasoning tokens from usage, so it is deferred tooDeferred, each equally red on
mainintegration-mcptest_mcp_rate_limits.py::test_shared_redis_enforces_paginated_tools_and_rest_listingsgets a rate-limit error on the continued page, red on main 91290 to 91294. Thenotifications/initializedlistener from 4a4a0e8 (feat(mcp): relay authorized modern upstream subscriptions #46153) spends the same server request budget astools/list, whether it should is a product callintegration-providerstest_responses_bridge_stream_errors.py::test_bridged_invalid_prompt_answers_a_bad_request_without_trying_the_fallback[nested|top_level]falls back on a 400 invalid prompt, the layer losing the 400 is not proven yet, leading suspect 83980c9 (fix(router): read the first stream chunk before returning so a failure before any token runs through the retry and fallback budget #46493)integration-providerstest_responses_bridge_tool_search_chaos.py::test_a_previous_response_id_turn_replays_the_function_call_without_the_search_callpins dropping the search call, while 9ba4cc4 (fix(anthropic): keep tool_search_tool_result so the search call replays with its result #46440) intentionally replays it with its result, a product call between the twointegration-extensionsfails a different chaos or OTel test on each runPre-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 moreScreenshots / Proof of Fix
Last updated: b2c054f. Before ran at merge base ecbea93 and After at d1f2333. The After leg re-ran at b2c054f, the last commit with a product diff, and matched d1f2333 on every case, shown last
Shared setup
/home/ubuntu/repos/litellm-mcpdiagatecbea93381782591e3e8bf90af145aa68163484a. After used/home/ubuntu/repos/litellmatd1f233306775b6b53a349b5fa08fe32388b57816127.0.0.1:46763and tip on127.0.0.1:46764, withLITELLM_LOCAL_MODEL_COST_MAP=True56763and56764. The Python import path resolved to the corresponding worktreeus-east-1. OpenAI calls used the real Shared-vault OpenAI item. Provider values were not printed, recorder authorization fields were redacted, and a scan found no credential values in the QA artifactsbedrock-runtime.us-east-1.amazonaws.comandapi.openai.com. All final measured provider calls returned HTTP 200bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0. Both revisions' price maps gave that key input1.1e-6and output5.5e-6. The bareanthropic.claude-haiku-4-5-20251001-v1:0key was1e-6and5e-6.gpt-4o-miniwas1.5e-7and6e-7bedrock-explicitsetinput_cost_per_token: 0.001andoutput_cost_per_token: 0.002.bedrock-base-modelused the same routable inference-profile model withmodel_info.base_model: anthropic.claude-haiku-4-5-20251001-v1:0Reply with the word OK.,max_tokens: 24, andtemperature: 0. Commands use$LITELLM_MASTER_KEYfor the local proxy keyus.inference profile. The first OpenAI recorder setup duplicated/v1and returned HTTP 404. Its upstream base was corrected before the successful OpenAI measurements. These setup attempts are excluded from the cases belowheadroom,remote_rig.py, andmitmdumphelpers were unavailable. Manual host resource checks were used, and the supplied local recorder was used for real provider traffic/home/ubuntu/work/qa_46763_artifacts/. Both proxy worktrees were clean, and all QA proxy, recorder, and PostgreSQL services were stopped after the measurementsBefore (ecbea93)
Bedrock route-priced Claude chat completions
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas3.63e-05Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowchatcmpl-c3c828b3-11c7-40eb-9d84-d194ed386bb1recorded 13 prompt tokens, 4 completion tokens, and spend3.63e-05. PassBedrock route-priced Claude streaming chat completions
Command
HTTP 200 SSE. The final usage event reported 13 prompt tokens, 4 completion tokens, and
cost: 0.0000363.x-litellm-response-costwas absent andx-litellm-response-cost-originalwas0.0Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowchatcmpl-8a458ec0-8fa4-4476-a0ff-b83e72d9f70erecorded 13 prompt tokens, 4 completion tokens, and spend3.63e-05. Pass for SSE cost and spend, with no nonzero response-cost headerBedrock Claude explicit deployment pricing
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas0.021Expected
13 * 0.001 + 4 * 0.002 = 0.021./spend/logsrowchatcmpl-d78da653-9c19-4264-ba65-76160297d131recorded 13 prompt tokens, 4 completion tokens, and spend0.021. PassBedrock Claude base_model pricing
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas3.3e-05Expected under
base_modelanthropic.claude-haiku-4-5-20251001-v1:0is13 * 1e-6 + 4 * 5e-6 = 3.3e-05./spend/logsrowchatcmpl-8d6af7da-470e-452c-b490-a9917f0b9822recorded 13 prompt tokens, 4 completion tokens, and spend3.3e-05. PassOpenAI gpt-4o-mini sanity check
Command
HTTP 200. Usage was 13 prompt tokens and 1 completion token.
x-litellm-response-costwas2.55e-06Expected
13 * 1.5e-7 + 1 * 6e-7 = 2.55e-06./spend/logsrowchatcmpl-EZZB1EOiYxTwWuoyppd4cUdDEgTB5recorded 13 prompt tokens, 1 completion token, and spend2.55e-06. PassBedrock Claude /v1/messages
Command
HTTP 200. Usage was 13 input tokens and 4 output tokens.
x-litellm-response-costwas3.3e-05Expected for the configured
us.anthropic...inference-profile key is13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowmsg_bdrk_pb62y3lxeubzrwnenosprh7w5mstuel5qkkx3d2rh6uo4lr3hyyqrecorded spend3.3e-05, matching the bare-model rate instead. FailBedrock Claude /v1/responses
Command
HTTP 200. Usage was 13 input tokens and 4 output tokens. The response body had
usage.cost: null, whilex-litellm-response-costwas3.63e-05Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowchatcmpl-e678d383-bddb-407d-8a0e-6c6b95cb45b9recorded 13 prompt tokens, 4 completion tokens, and spend3.63e-05. Pass for header and spendAfter (d1f2333)
Bedrock route-priced Claude chat completions
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas3.63e-05Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowchatcmpl-a54740db-e318-4e31-b20c-41cb8c65e9a9recorded 13 prompt tokens, 4 completion tokens, and spend3.63e-05. PassBedrock route-priced Claude streaming chat completions
Command
HTTP 200 SSE. The final usage event reported 13 prompt tokens, 4 completion tokens, and
cost: 0.0000363.x-litellm-response-costwas absent andx-litellm-response-cost-originalwas0.0Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowchatcmpl-faf74629-2a01-4a82-bc27-2a81f8bc7e89recorded 13 prompt tokens, 4 completion tokens, and spend3.63e-05. Pass for SSE cost and spend, with no nonzero response-cost headerBedrock Claude explicit deployment pricing
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas0.021Expected
13 * 0.001 + 4 * 0.002 = 0.021./spend/logsrowchatcmpl-f52a42cd-7e18-407f-8394-08f05b04cb79recorded 13 prompt tokens, 4 completion tokens, and spend0.021. PassBedrock Claude base_model pricing
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas3.3e-05Expected under
base_modelanthropic.claude-haiku-4-5-20251001-v1:0is13 * 1e-6 + 4 * 5e-6 = 3.3e-05./spend/logsrowchatcmpl-f9cc6ec9-d7eb-45a6-81be-bfd41e49c17brecorded 13 prompt tokens, 4 completion tokens, and spend3.3e-05. PassOpenAI gpt-4o-mini sanity check
Command
HTTP 200. Usage was 13 prompt tokens and 1 completion token.
x-litellm-response-costwas2.55e-06Expected
13 * 1.5e-7 + 1 * 6e-7 = 2.55e-06./spend/logsrowchatcmpl-EZZB22QqYsuT5Kmm991nYWRT9HpThrecorded 13 prompt tokens, 1 completion token, and spend2.55e-06. Pass with unchanged base/tip costBedrock Claude /v1/messages
Command
HTTP 200. Usage was 13 input tokens and 4 output tokens.
x-litellm-response-costwas3.3e-05Expected for the configured
us.anthropic...inference-profile key is13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowmsg_bdrk_2bq5mjk3ti3aia5t4uz75fadcrkv5uv4oozrgvqvquaupeyjtigqrecorded spend3.3e-05, matching the bare-model rate instead. FailBedrock Claude /v1/responses
Command
HTTP 200. Usage was 13 input tokens and 4 output tokens. The response body had
usage.cost: null, whilex-litellm-response-costwas3.63e-05Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05./spend/logsrowchatcmpl-6cdaf0bb-0000-4e82-b5c6-23c1bf9e2808recorded 13 prompt tokens, 4 completion tokens, and spend3.63e-05. Pass for header and spendAfter (
b2c054f43e0affb0bc471ff6de90d6f41c906d65)1. Bedrock route-priced Claude chat completions
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas3.63e-05Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05. Spend rowchatcmpl-e0542e1e-9c08-48f9-be3f-b8dfb4fa7e1crecorded 13 prompt tokens, 4 completion tokens, and3.63e-05Outbound count was one Bedrock
POST /model/us.anthropic.claude-haiku-4-5-20251001-v1%3A0/converse, with body keysinferenceConfigandmessages. Compared withd1f2333, status, header cost, spend, and request shape/count were unchanged. Its spend row waschatcmpl-a54740db-e318-4e31-b20c-41cb8c65e9a9at3.63e-05. Pass2. Bedrock route-priced Claude streaming chat completions
Command
HTTP 200 SSE. The final usage event reported 13 prompt tokens, 4 completion tokens, and
cost: 0.0000363.x-litellm-response-costwas absent andx-litellm-response-cost-originalwas0.0Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05. Spend rowchatcmpl-4ffdc660-4ae9-422d-bcf8-1d4bae112d50recorded 13 prompt tokens, 4 completion tokens, and3.63e-05Outbound count was one Bedrock
POST /model/us.anthropic.claude-haiku-4-5-20251001-v1%3A0/converse-stream, with body keysinferenceConfigandmessages. Compared withd1f2333, status, absent cost header, SSE cost, spend, and request shape/count were unchanged. Its spend row waschatcmpl-faf74629-2a01-4a82-bc27-2a81f8bc7e89at3.63e-05. Pass for SSE cost and spend, with no nonzero response-cost header3. Bedrock explicit deployment pricing
Command
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas0.021Expected
13 * 0.001 + 4 * 0.002 = 0.021. Spend rowchatcmpl-73260f04-ae7a-4715-8b80-2d103aba9cffrecorded 13 prompt tokens, 4 completion tokens, and0.021Outbound count was one Bedrock
POST /model/us.anthropic.claude-haiku-4-5-20251001-v1%3A0/converse, with body keysinferenceConfigandmessages. Compared withd1f2333, status, header, spend, and request shape/count were unchanged. Its spend row waschatcmpl-f52a42cd-7e18-407f-8394-08f05b04cb79at0.021. Pass4. Bedrock
base_modelpricingCommand
HTTP 200. Usage was 13 prompt tokens and 4 completion tokens.
x-litellm-response-costwas3.3e-05Expected under
base_modelanthropic.claude-haiku-4-5-20251001-v1:0is13 * 1e-6 + 4 * 5e-6 = 3.3e-05. Spend rowchatcmpl-4191a7ed-46df-438b-8084-cf484f20a810recorded 13 prompt tokens, 4 completion tokens, and3.3e-05Outbound count was one Bedrock
POST /model/us.anthropic.claude-haiku-4-5-20251001-v1%3A0/converse, with body keysinferenceConfigandmessages. Compared withd1f2333, status, header, spend, and request shape/count were unchanged. Its spend row waschatcmpl-f9cc6ec9-d7eb-45a6-81be-bfd41e49c17bat3.3e-05. Pass5. OpenAI
gpt-4o-minisanity checkCommand
HTTP 200. Usage was 13 prompt tokens and 1 completion token.
x-litellm-response-costwas2.55e-06Expected
13 * 1.5e-7 + 1 * 6e-7 = 2.55e-06. Spend rowchatcmpl-EZaVgRdLvOiIsZJSzbQ7qKIDLrWUhrecorded 13 prompt tokens, 1 completion token, and2.55e-06The case emitted one OpenAI
POST /v1/chat/completions, with body keysmax_tokens,messages,model, andtemperature. Compared withd1f2333, status, header, spend, and case request shape/count were unchanged. Its spend row waschatcmpl-EZZB22QqYsuT5Kmm991nYWRT9HpThat2.55e-06. Pass6. Bedrock Claude
/v1/messagesCommand
HTTP 200. Usage was 13 input tokens and 4 output tokens.
x-litellm-response-costwas3.3e-05Expected for the configured inference-profile key is
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05. Spend rowmsg_bdrk_xdfzfhxstkt43ozuets7fegqiekrokivl3uf6nwbcd7dxrriuwuarecorded 13 input tokens, 4 output tokens, and3.3e-05, matching the bare-model rate. FailOutbound count was one Bedrock
POST /model/us.anthropic.claude-haiku-4-5-20251001-v1:0/invoke, with body keysanthropic_version,max_tokens, andmessages. Compared withd1f2333, status, header, spend, and request shape/count were unchanged. Its spend row wasmsg_bdrk_2bq5mjk3ti3aia5t4uz75fadcrkv5uv4oozrgvqvquaupeyjtigqat3.3e-05. The inference-profile cost discrepancy remains7. Bedrock Claude
/v1/responsesCommand
HTTP 200. Usage was 13 input tokens and 4 output tokens. The response body had
usage.cost: null, whilex-litellm-response-costwas3.63e-05Expected
13 * 1.1e-6 + 4 * 5.5e-6 = 3.63e-05. Spend rowchatcmpl-2a0a0f5c-a1d9-43c0-92ad-3ba890f30cbcrecorded 13 prompt tokens, 4 completion tokens, and3.63e-05Outbound count was one Bedrock
POST /model/us.anthropic.claude-haiku-4-5-20251001-v1%3A0/converse, with body keysinferenceConfigandmessages. Compared withd1f2333, status, header, spend, and request shape/count were unchanged. Its spend row waschatcmpl-6cdaf0bb-0000-4e82-b5c6-23c1bf9e2808at3.63e-05. Pass for header and spend, with response-bodyusage.coststill nullType
🐛 Bug Fix
✅ Test
Caveats (if any)
Low
test_stream_chunk_builder_skips_stamp_when_cost_is_unpriceablenow uses an unmapped model so it still pins the unpriceable pathget_model_infolookups per callintegration-coston main vs this branch is the before and after proof/v1/messagesbills the bare model rate instead of the inference-profile rate on both base and tip, unchanged by this PRFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/d72818716aa244298b2930abebb17387
Open in Devin Desktop: https://app.devin.ai/desktop/session/d72818716aa244298b2930abebb17387?variant=devin
Requested by: @mateo-berri
Note
Medium Risk
Changes core spend calculation ordering and Bedrock prompt-cache pin lifetime, which can shift logged costs and routing pins; scope is well covered by new unit and integration tests.
Overview
Fixes $0 billing when a response-derived model name matches a price-free Claude capability rule before a route-priced Bedrock (or similar) entry in the cost map.
completion_costnow ranks candidates as (model, pricing provider) pairs, classifies unpriced generalized matches, and tries exact cost-map names before capability-only fallbacks (priced generalization rules keep their place; explicitcustom_pricing/base_modelskips reordering). Provider passed intocost_per_tokenis resolved via_pricing_provider_for_cost_candidate.Bedrock prompt-cache pinning now decides one-hour TTL with the same
bedrock_capability_model+bedrock_cache_point_ttl_supportedpath as the wire, using deploymentmodelandbase_modelfromlitellm_params(fixes ARN +base_modelprofiles pinned at 5m while sendingttl: 1h).Integration/CI hardening: isolated worker configs copy sibling auth
.pymodules (and symlink.jsonstate); SCIM chaos test kills all serving workers after a row-lock block instead of matching Postgresclient_portto host sockets; MCP OAuth expectations addservers: null; spend rollup expectsptu_hours; Bedrock realtime peer usesallocate_port; Nova Sonic test assertsresponse.function_call_arguments.delta.Unit tests cover cost candidate ordering, Bedrock profile 1h TTL, worker config isolation, and stream chunk builder pricing for priced deployment aliases.
Reviewed by Cursor Bugbot for commit 2643fff. Bugbot is set up for automated code reviews on this repo. Configure here.