Skip to content

fix(decisions): bill unpriced returned TypeSafe versions at the requested model and name a missing answers field - #47508

Merged
yuneng-berri merged 10 commits into
mainfrom
litellm_bill_completed_callbacks_once
Oct 20, 2026
Merged

yuneng-berri merged 10 commits into
mainfrom
litellm_bill_completed_callbacks_once

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

A typesafe/jev-latest decision bills $0 when TypeSafe answers as a version the proxy serves but the cost map does not price yet, since pricing used the empty row the router registers for every served deployment. This PR still prices by the returned version when its row has rates, and falls back to the requested deployment's rates when it has none

It also answers every System One reply that fails the response schema with a 500 naming the field at fault, so reply text such as an answer named rate_limit no longer turns it into a 429. The Arize tests now expect litellm.cache_hit and one cache-hit span carrying it, as #47364 set up

Original

TLDR

Problem this solves:

  • Unpriced returned TypeSafe versions bill $0
  • Malformed System One replies fail with an error naming nothing
  • Some come back as 429 or 408
  • Arize span tests predate the litellm.cache_hit attribute

How it solves it:

  • Price by the returned version only when its row has rates
  • Otherwise price at the requested model's rates
  • Let the response schema name the missing or null field
  • Answer every schema failure with a 500
  • Find the Arize cache-hit span by its attribute

User Flow

Before, a TypeSafe call bills $0 when TypeSafe answers as a version the cost map does not price yet

  1. The proxy serves typesafe/jev-latest and typesafe/jev-1.13.0, and its cost map has no typesafe/jev-1.13.0 row
  2. POST http://localhost:4000/v1/decisions with "model":"typesafe/jev-latest" is answered as jev-1.13.0, with no x-litellm-response-cost header
  3. GET http://localhost:4000/spend/logs?api_key= shows spend 0.0 for 287 input tokens

After, the same call bills at typesafe/jev-latest's rates

  1. The same proxy and cost map
  2. The same POST http://localhost:4000/v1/decisions carries x-litellm-response-cost: 1.2054e-05
  3. GET http://localhost:4000/spend/logs?api_key= shows spend 1.2054e-05

Before, a TypeSafe deployment whose api_base answers 200 without answers fails with an error naming no field

  1. POST http://localhost:4000/v1/decisions to that deployment returns 500 with 1 validation error for dict[str,any] ... input_value=None

After, the same call says answers is missing

  1. The same POST returns 500 with DecisionsResponse answers: Field required

Relevant issues

Replaces #47047, which stampbot rated high risk. #47510 now carries its double-billing fix

CircleCI

Red on main's scheduled integration workflow since pipeline 91315: the two typesafe/jev-latest cases of integration-cost, the decisions wire test in integration-providers, and 11 Arize cases in integration-extensions. Through tests/integration/run.py they pass here and fail on the merge base

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Screenshots / Proof of Fix

Proxies from 2c6b280 (merge base) and bba5033 (head), 2 uvicorn workers each, own Postgres and Redis, the same config, real TypeSafe, OpenAI and OpenRouter calls, and a fresh key per case, with raw outputs

Case Before After Before spend After spend
TypeSafe unlisted version, decisions no cost header 1.2054e-05 0.0 1.2054e-05
Same, System One no cost header 1.2054e-05 0.0 1.2054e-05
TypeSafe priced version 2.87e-05 2.87e-05 2.87e-05 2.87e-05
Reply without answers 500, no field 500, answers none none
Same, rate-limit or timeout text 500, no field 500, answers 0.0 0.0
Null answer named rate_limit, both routes 500, no field 500, answers.rate_limit 0.0 0.0
Chat via OpenRouter base_model 3.225e-05 3.225e-05 3.225e-05 3.225e-05
Chat via OpenAI base_model 2.775e-05 2.775e-05 2.775e-05 2.775e-05

Before (2c6b280)

TypeSafe unlisted version

The proxy loads its cost map from LITELLM_MODEL_COST_MAP_URL, this commit's own map minus the typesafe/jev-1.13.0 and typesafe/jev-1.14.0 rows

  1. curl -s localhost:$PORT/model/info -H "Authorization: Bearer $MASTER" shows input_cost_per_token 4.2e-08 for typesafe/jev-latest and null for typesafe/jev-1.13.0
  2. curl -si localhost:$PORT/v1/decisions -H "Authorization: Bearer $KEY" -H 'content-type: application/json' -d '{"model":"typesafe/jev-latest","input":"Ticket (billing): The export job hangs at 99% and never finishes","questions":[{"type":"predicate","name":"defect","instructions":"Is this a defect?"}]}'
  3. Wait 20 seconds, then curl -s "localhost:$PORT/spend/logs?api_key=$KEY" -H "Authorization: Bearer $MASTER"

Raw output

HTTP/1.1 200 OK
x-litellm-model-name: typesafe/jev-latest
x-litellm-response-cost-original: 0.0
x-litellm-response-cost-input: 0.0
{"model":"jev-1.13.0","answers":[{"type":"predicate","name":"defect","probability":0.87}],"usage":{"input_tokens":287,...,"output_tokens":21,...,"total_tokens":308}}

[{"request_id":"cd02a748-5334-4c81-b632-6c82780bd9e2","call_type":"adecisions",...,"spend":0.0,"total_tokens":308,"prompt_tokens":287,...,"model":"typesafe/jev-latest",...}]

After (bba5033)

TypeSafe unlisted version

The same three steps and the same map edit

Raw output

HTTP/1.1 200 OK
x-litellm-model-name: typesafe/jev-latest
x-litellm-response-cost: 1.2054e-05
x-litellm-response-cost-original: 1.2054e-05
x-litellm-response-cost-input: 1.2054e-05
{"model":"jev-1.13.0","answers":[{"type":"predicate","name":"defect","probability":0.87}],"usage":{"input_tokens":287,...,"output_tokens":21,...,"total_tokens":308}}

[{"request_id":"49db97fb-5296-48f1-92c6-b25e99b75447","call_type":"adecisions",...,"spend":1.2054e-05,"total_tokens":308,"prompt_tokens":287,...,"model":"typesafe/jev-latest",...}]
Every other case

Same, through System One

The same proxy, then curl -si localhost:$PORT/v1/systemone -H "Authorization: Bearer $KEY" -H 'content-type: application/json' -d '{"model":"typesafe/jev-latest","state":"Ticket (billing): The export job hangs at 99% and never finishes","questions":{"defect":{"type":"noul","instructions":"Is this a defect?"}}}' with a fresh key. TypeSafe answers as jev-1.13.0 with 287 input tokens on both commits. Before, there is no x-litellm-response-cost header and the spend-log row reads 0.0. After, the header and the row read 1.2054e-05. Before, after

TypeSafe priced version

This is the control for a returned version whose row has rates. The proxy loads a map where only typesafe/jev-1.13.0's input_cost_per_token is 1e-07, and /model/info shows 4.2e-08 for typesafe/jev-latest and 1e-07 for typesafe/jev-1.13.0. The same /v1/decisions call, answered as jev-1.13.0 with 287 input tokens, costs 2.87e-05 (287 x 1e-07) on both commits, never 1.2054e-05 at jev-latest's rate, and its spend-log row matches. Before, after

Reply without answers

A deployment typesafe-misrouted with model: typesafe/jev-latest and api_base: https://httpbin.org/anything, a real server that answers 200 with an echo of the request and no answers field, stands in for an api_base pointed at a host that is not TypeSafe. curl -si localhost:$PORT/v1/decisions -H "Authorization: Bearer $KEY" -H 'content-type: application/json' -d '{"model":"typesafe-misrouted","input":"Ticket (billing): The export job hangs at 99% and never finishes","questions":[{"type":"predicate","name":"defect","instructions":"Is this a defect?"}]}' returns 500 internal_server_error on both commits. Before, the message reads 1 validation error for dict[str,any] Input should be a valid dictionary [type=dict_type, input_value=None, input_type=NoneType]. After, it reads DecisionsResponse answers: Field required. Before, after

Reply without answers whose text reads like a rate limit or a timeout

Two Perplexity deployments on perplexity/pplx-decider-v1-27b point api_base at https://httpbin.org/response-headers?error=<text>#, which answers 200 with {"error": "Rate limit reached"} or {"error": "Request timed out"} and no answers. Perplexity's error mapping reads message text, so these are the replies a text match could turn into a 429 or a 408. curl -si localhost:$PORT/v1/systemone -H "Authorization: Bearer $KEY" -H 'content-type: application/json' -d '{"model":"pplx-ratelimit-text","state":"Ticket (billing): The invoice PDF download returns a blank page","questions":{"defect":{"type":"noul","instructions":"Is this a defect?"}}}', and the same with pplx-timeout-text, return 500 internal_server_error on both commits. After, the message reads DecisionsResponse answers: Field required with none of the upstream text. Before, after

Null answer named rate_limit

Deployment pplx-null-rate-limit on perplexity/pplx-decider-v1-27b points api_base at a hosted endpoint that answers 200 with {"model":"pplx-decider-v1-27b","answers":{"rate_limit":null},"usage":{"input_tokens":10,"output_tokens":0}}. curl -si localhost:$PORT/v1/systemone -H "Authorization: Bearer $KEY" -H 'content-type: application/json' -d '{"model":"pplx-null-rate-limit","state":"Ticket (billing): The card was charged twice after a retry","questions":{"rate_limit":{"type":"noul","instructions":"Is this about a rate limit?"}}}', and the same question through /v1/decisions, return 500 internal_server_error on both commits, never 429. Before, the message names no field. After, it reads DecisionsResponse answers.rate_limit: Input should be a valid dictionary or object to extract fields from. Before, after

Chat through base_model

This PR also touches the helper that checks whether a cost-map row has rates when a deployment sets base_model. Two deployments set base_model: gpt-5.4-mini, one on openrouter/openai/gpt-5.4-mini (no cost-map row of its own) and one on openai/gpt-5.4-mini. curl -si localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'content-type: application/json' -d '{"model":"<model>","messages":[{"role":"user","content":"Reply with BASE and nothing else."}],"max_completion_tokens":32}' costs 3.225e-05 through OpenRouter and 2.775e-05 through OpenAI on both commits, which is gpt-5.4-mini's 7.5e-07 and 4.5e-06 rates, and each spend-log row matches. Before, after

Things the run saw that this PR leaves alone

  • Spend-log rows name the requested model, not the answered one

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Low

  • Only TypeSafe and Perplexity ran live, other providers share the parser
  • Chat keeps the unpriced-snapshot $0 gap, since every provider shares that price selection
  • Calls that billed $0 for an unpriced answered version now bill
  • Another deployment's custom price for the answered version is never used
  • The 500 drops the bad value, and nothing logs the raw reply
  • The branch name still says callbacks from the replaced scope
/live-pr-risk at bba5033

Both legs ran 2 uvicorn workers with their own Postgres and Redis, and forwarding recorders sat in front of httpbin.org and api.typesafe.ai, so every upstream attempt was counted. A third leg ran the head merged with main 4b19283

Breaking

None. Every cell that answers differently at bba5033 maps to a change listed below, and the merged leg matched the head on every cell

Backward incompatible

  • A malformed JSON reply answers 500 internal_server_error whatever its text. Live, {"answers": "Request timed out"} went from 408 to 500 on TypeSafe and a rate-limit text from 429 to 500 on Fireworks AI, and in-process 68 of 264 provider and reply pairs changed class. Decided in af1f588 by mateo-berri, the PR author, in line with test_upstream_success_without_answers_is_a_gateway_side_server_error from feat(decisions): add unified /v1/decisions endpoint for Jev-compatible providers #44236, which already holds a reply without answers to a gateway-side 5xx
  • The message names the field and drops the upstream input, and the openai prefix reads OpenaiException instead of OpenAIException. Fixed in 1c347fb and af1f588, decided by mateo-berri
  • model_group_retry_policy reads the new class, so a group with TimeoutErrorRetries: 2, InternalServerErrorRetries: 0 sends 1 attempt instead of 3. Decided in af1f588 by mateo-berri, since a malformed reply is a provider fault and a retry gets the same reply
  • Prometheus exception_class and exception_status, the spend log's error_class and error_code, and the /health text move from Timeout 408 or RateLimitError 429 to InternalServerError 500. Decided in af1f588 by mateo-berri for the same reason
  • The complexity router's breaker no longer opens on a classifier whose malformed reply reads Request timed out, since it opens only on a real litellm.Timeout. Every request still answered 200. Decided in af1f588 by mateo-berri, as this matches the breaker's design
  • A returned version whose cost-map row has no rates bills at the requested model, 1.2054e-05 instead of $0. This is the PR's purpose, decided by mateo-berri
  • cost_map_key_prices_anything is a new public helper in litellm/cost_calculator.py, which is additive

Regression risk

  • A 2xx body that is not JSON still maps by its text on both trees, so Request timed out is a 408. This was seen in-process, and live an empty body answered 500 on both trees. It is pre-existing and filed as a follow-up
  • allowed_fails_policy now counts these failures under InternalServerErrorAllowedFails. This was traced, not observed
  • Neither tree cooled down the bad deployment in a two-deployment proxy group, though an SDK Router did on the base
  • Datadog and OTEL error.type and the include_fallback_errors headers should follow the spend row's error_class, but no exporter was wired
  • openrouter's float(cost) can raise OverflowError on a huge integer. This is pre-existing and was reasoned, not run

Dependency graph

Dependent path Status
/v1/systemone status and body live, unit
/v1/decisions status and body live, unit
model_group_retry_policy live, no test
allowed_fails_policy no test
Deployment cooldown live, same on both
Prometheus labels live, no test
Spend error_class live, no test
Datadog and OTEL error.type no test
Fallback error headers no test
/health text live
Complexity router breaker live, unit
decision_model guardrail live, same on both
Non-JSON 2xx body live (empty), in-process
_pricing_model live, unit

Unit tests at the head gave 3360 passed and 2 failed, and both failures are timing tests that pass alone on both trees. The integration lanes for decisions, cost, Arize, proxy logs, spend and management had 10 reds at the head, and all 10 fail on the base too

Not verified

The Fireworks AI happy path, since its router answers 404 on both trees. Live calls for azure_ai, hosted_vllm, cloudflare, bespoke, laya, nace and strands_decider, which ran in-process and on the integration lane's scripted upstream only. A raw-text 2xx body live, allowed_fails_policy live, the exporters' error.type, and the decisions playground UI spec

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
Bugbot summary

[!NOTE]
Medium Risk
Changes billing for unpriced returned model IDs (intended fix, may increase spend) and reclassifies some malformed 2xx bodies from rate-limit/timeout errors to 500 InternalServerError, affecting retries and observability labels.

Overview
Fixes $0 billing when a decisions/System One call returns a model version whose cost-map row exists but has no rates (e.g. TypeSafe answering as an unpriced deployment). provider_response_model now uses the returned model only if cost_map_key_prices_anything says that key is billable; otherwise pricing falls back to the requested deployment model. The same helper refactors _declares_rates for base-model pricing checks.

Malformed upstream JSON is normalized more safely before Pydantic validation, and schema failures raise DecisionsResponseValidationError with a short field-level summary (e.g. missing answers) instead of generic dict errors or message-text matches that could surface as 429/408. Those failures map to InternalServerError in the decisions call path.

Integration tests for Arize/OpenInference now assert litellm.cache_hit on spans (including cache-hit spans with zero cost). Unit tests cover unpriced returned models, expanded malformed-reply cases, and System One field naming on validation errors.

Reviewed by Cursor Bugbot for commit bba5033. Bugbot is set up for automated code reviews on this repo. Configure here.

…cision models at the requested model

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot

@kerry-berri

kerry-berri commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

litellm-stampbot: risk low

Approved at 3c43bce.

Rules (stampbot/risk_rules.yml):

  • low: 0 changed source lines (only tests, docs, cookbook, markdown or the cost map changed), approved without asking Bugbot or the judge

Judge: skipped, the rules alone decided.

Pushes do not re-run this check. Comment @litellm-stampbot again to re-check the new head.

@kerry-berri kerry-berri added the risk:low Small, isolated, low-risk change label Oct 20, 2026

@kerry-berri kerry-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low risk by rule and by judgement at 3c43bce

@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ision models only when they carry rates

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
@codspeed

codspeed Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 32 untouched benchmarks


Comparing litellm_bill_completed_callbacks_once (bba5033) with main (9bbf70e)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (2c6b280) during the generation of this report, so 9bbf70e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

⚠️ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

Completed · Some checks not run.

No correctness findings.

Checks and execution details
  • Passed · Real testing evidence (required): In scope: litellm/llms/base_llm/decisions/transformation.py changes how decisions responses are parsed and turns schema failures into a new DecisionsResponseValidationError (500) with a field-level message. The pricing change in litellm/decisions/call.py and cost_calculator.py sits outside the scoped paths.

The gist holds inspectable manual E2E evidence. The author ran proxies at head bba5033c27 and base 2c6b280755 with 2 workers, Postgres, Redis and the posted 0_config.yaml, then sent real requests to /v1/systemone and /v1/decisions. I read the raw captures:

  • after_11: an upstream reply with no answers returns 500 internal_server_error with DecisionsResponse answers: Field required, for both rate-limit and timeout text.
  • after_12: answers: {rate_limit: null} returns 500 with answers.rate_limit: Input should be a valid dictionary.

Those upstreams are httpbin and webhook.site endpoints that return the malformed body. They run through the real Perplexity adapter and the proxy, which fits a malformed-reply case.

Unit tests also cover the missing, null, non-object and misleading-text shapes: test_a_malformed_upstream_reply_is_a_server_error_whatever_its_text and test_a_malformed_systemone_response_names_the_field_at_fault.

  • Passed · Compatibility requirements (required): I found no break to supported behavior.

  • A schema-invalid decisions reply already failed before this PR. It used to return 500 from exception_type and could become 429 or 408 if the upstream text matched. It now always returns 500 with a different message. Only the misclassified failures change status.

  • An unpriced returned version used to bill $0 because of the empty router-registered row. It now bills at the requested model's rates, which is a billing fix.

  • A priced returned version still bills by the returned key (_pricing_model checks cost_map_key_prices_anything first).

  • _declares_rates keeps the same semantics after the extraction.

No marker is needed.

  • Passed · Changed behavior and result consistency (required): Read root AGENTS.md, tests/AGENTS.md, tests/unit/AGENTS.md and tests/integration/AGENTS.md.

Pricing path: _format_response → provider_response_model hidden param → select_model_name_for_cost_calc (cost_calculator.py ~1002). The custom_pricing and base_model branches still take precedence there. I checked these cases:

  • returned key missing → requested model
  • returned row empty {} or null-rate → requested model
  • returned row priced → returned key

The two unpriced cases are tested in test_a_returned_model_registered_without_prices_is_billed_at_the_requested_model.

Error path: transform_decisions_response raises DecisionsResponseValidationError. Both asend and send reach _map_upstream_exception, whose first match arm turns it into InternalServerError. The arm order beats the synthesized-status arm. Fireworks and Strands Decider reach it through super(). OpenAI parse_response raises ValidationError, which the same base wrapper catches.

_normalize_systemone_response returns non-mapping payloads and answers unchanged, so pydantic reports the location. That covers the not_an_object case.

Prior Arize finding: the span is now selected by attribute.

  • Passed · Unit tests for decisions (optional): .venv/bin/python -m pytest -q tests/unit/decisions/test_main.py tests/unit/llms/base_llm/decisions/test_base_decisions_transformation.py -n 4 → 319 passed.
  • Not run · Arize integration tests (extensions group) (optional): Not rerun in this pass. The earlier review run at head 5bbc85e ran them, and the selection code at lines 972-977 is unchanged in this checkout.

View review · Reviewed bba5033c2717

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable issues found

Summary

This PR bills unpriced returned decisions models at the requested model’s rates. Returned models with declared rates still use their own prices

It also names malformed response fields and returns 500 for schema failures. The Arize tests now find cache-hit spans by litellm.cache_hit instead of their position

The earlier, unnumbered finding about missing live error-path proof is addressed by the proxy examples supplied by mateo-berri. No new actionable issues were found

  • Decision calls use the requested model's rates when a returned version has no price.
  • Malformed System One replies name the field that failed and return a 500.
  • Arize span tests identify cache hits by their cache flag.

Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…ecisions pricing and missing-answers fixes
@mateo-berri mateo-berri changed the title fix(logging,decisions): bill each request once and price returned decision models only when they carry rates fix(decisions): bill unpriced returned TypeSafe versions at the requested model and name a missing answers field Oct 20, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

1 similar comment
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 20, 2026

Copy link
Copy Markdown

Review already requested

code-review is already reviewing 62058c4492cc. View existing review.

)
assert len(marker_spans) == 2, spans
_assert_tool_span_for_marker(marker_spans[1], marker)
assert marker_spans[1]["litellm.cache_hit"] == "True", marker_spans

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium · New cache-hit span assertion fails because the test picks the span by arrival order

  1. test_arize_otel_v2_cache_hit_exports_llm_span makes a chat call for marker, then repeats it as a cache hit.
  2. The test gathers the two marker LLM spans in the order the OTLP receiver drained them. It assumes marker_spans[1] is the cache hit.
  3. In practice, the cache-hit span gets exported first, so marker_spans[0] is the hit (cache_hit="True", cost 0.0) and marker_spans[1] is the original call ("False", 4.05e-06).
  4. The new assert marker_spans[1]["litellm.cache_hit"] == "True" fails. I saw it fail in 3 of 3 runs against this head. The extensions group runs this file on main, so the suite this PR is meant to turn green would gain a new red.

Smallest fix: pick the span with litellm.cache_hit == "True", the same way this PR's test_arize_otel_v2_a_cache edit does, instead of indexing by position.

Evidence

Command: INTEGRATION_WORKERS=2 python tests/integration/run.py extensions tests/integration/observability/test_arize_otel_v2_openinference_spans.py::test_arize_otel_v2_cache_hit_exports_llm_span with local Postgres 15 and Redis.

Result: E assert 'False' == 'True' at assert marker_spans[1]["litellm.cache_hit"] == "True". It failed once in the batch run (11 other selected Arize cases passed) and in 2 of 2 isolated reruns.

A temporary debug print, since removed, showed [(cache_hit, cost.total) for s in marker_spans] == [('True', '0.0'), ('False', '4.05e-06')] on both reruns. The hit is at index 0.

The existing _assert_tool_span_for_marker(marker_spans[1], marker) passes for either span, so the ordering assumption had never been tested until this PR added attribute assertions on [1].

tests/integration/AGENTS.md: CircleCI integration groups run on main, not on pull requests, so this failure first shows up after merge.

Latest summary by code-review · View this review · Reviewed 62058c4492cc

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

1 similar comment
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 20, 2026

Copy link
Copy Markdown

Review already requested

code-review is already reviewing 5bbc85ec9d9f. View existing review.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 20, 2026

Copy link
Copy Markdown

Review already requested

code-review is already reviewing 4eb5b6809b20. View existing review.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…tever text it carries

A reply that fails the decisions response schema now raises
DecisionsResponseValidationError, which the decisions call maps straight to
InternalServerError instead of passing it through exception_type. Its text
matching read an answer key like rate_limit, or a value like "Request timed
out", as a 429 or a 408, so the router cooled down a deployment for a reply
that fails the same way on every retry.

The message also drops the empty location for a reply that is not an
object, the Arize family test loses the cache_hit entries main already
added, and the Bedrock Mantle count-tokens wire test calls
_metadata_deployment, since main renamed the _deployment helper under it.
…d_callbacks_once

# Conflicts:
#	tests/integration/providers/test_bedrock_mantle_count_tokens_wire.py
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yuneng-berri
yuneng-berri merged commit 81d8c9a into main Oct 20, 2026
91 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_bill_completed_callbacks_once branch October 20, 2026 18:46
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 bba5033. Configure here.

@tavren27 tavren27 mentioned this pull request Oct 28, 2026
6 tasks done
@mateo-berri

Copy link
Copy Markdown
Contributor Author

The post-merge audit of this change is #48777, and every behavior it fixed holds at the merge commit and fails at its parent

mateo-berri added a commit that referenced this pull request Oct 28, 2026
* test(decisions): audit #47508

* test(decisions): price the Databricks decision cell from its cost-map row

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
mateo-berri added a commit that referenced this pull request Nov 19, 2026
… on main

Drop the Router override that let a caller base_url replace a deployment's
own api_base. Main's prepare_call reads base_url only when no api_base is
set, and the router now merges the caller kwargs the same way, so the LTS
line matches main's precedence.

Also drop the list-form score legend normalization from the #47508 port.
It came from #46523 on main, and neither LTS provider that reaches it
(Gemini, TypeSafe) sends a list legend.

Cover the sync Router credential guard for both URL parameter names.
mateo-berri added a commit to owen-hj/litellm that referenced this pull request Nov 23, 2026
Backport of BerriAI#47508 to lts/1.108.x (prerequisite of BerriAI#51220).
Cherry-picked from 81d8c9a (main).
Minimal hand-port of response validation, omitting unrelated pricing and observability changes.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Small, isolated, low-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants