Skip to content

refactor(typing): clear basedpyright Any errors across 35 files - #53599

Merged
mateo-berri merged 9 commits into
BerriAI:mainfrom
edvinsq:beluga_decrease_anys_20261121
Nov 24, 2026
Merged

mateo-berri merged 9 commits into
BerriAI:mainfrom
edvinsq:beluga_decrease_anys_20261121

Conversation

@edvinsq

@edvinsq edvinsq commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

This replaces loose Any types with real ones in 35 files so the type checker can catch bugs it could not see before. Nothing a user sends or gets back changes

Details

TLDR

Problem this solves:

  • Main has 1,138 basedpyright Any errors hiding unchecked values
  • The type checker cannot catch bugs behind them

How it solves it:

  • Replaces Any with real types across 35 files
  • Narrows untyped values with the repo's existing typed helpers
  • Changes no request, response, error or spend behavior
  • Leaves the proxy client SDK and vector store params as main has them, since typing them changed what callers see

User Flow

Before: an admin's key lookup, a user's streamed chat and responses calls, router fallbacks and the metrics page all behave normally

  1. The admin sends POST https://litellm-domain/v2/key/info with {"keys": ["sk-..."]} and the master key, and gets 200 with each key's owner, team and budget settings but no raw token
  2. A user sends POST https://litellm-domain/v1/chat/completions with "stream": true and receives data: chunks ending in data: [DONE]
  3. The same user sends POST https://litellm-domain/v1/responses with "stream": true and receives events through response.completed
  4. A deployment that keeps failing is cooled down, and the user's next POST https://litellm-domain/v1/chat/completions returns 200 from the fallback deployment
  5. The operator opens GET https://litellm-domain/metrics and sees the usual Prometheus series with their labels

After: the same five steps return the same status codes, response bodies, stream events and metrics, since this PR only narrows type annotations

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

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Before is the merge base a1df18d and after is c66f8a4, with the same result on every case. Commits 8d9afd4 and e74b46f, a merge with main, carry this proof, as the notes at the end explain.

Both legs ran on one GCE host. Each had two proxies, P and Q, with 2 workers each, sharing the leg's own Postgres and Redis, so state written through P is read back through Q. All provider calls are real (OpenAI gpt-6.2-sol, Anthropic claude-haiku-5-5, DashScope qwen3-rerank).

Proxy command, config, env vars and client

Each of the four proxies ran this, from its leg's checkout:

.venv/bin/python litellm/proxy/proxy_cli.py --config config.yaml --host 127.0.0.1 --port <port> --num_workers 2 --timeout_worker_healthcheck 60 --telemetry False --use_prisma_db_push

This is the QA rig's command, not the AGENTS.md one. It drops --reload and --detailed_debug so both workers serve, and pushes the schema once per leg before boot. Each proxy had 2 worker PIDs, and both trees were clean at the stated commit.

Env var names: OPENAI_API_KEY, ANTHROPIC_API_KEY, DASHSCOPE_API_KEY, DASHSCOPE_API_BASE, LITELLM_MASTER_KEY, LITELLM_SALT_KEY, DATABASE_URL, REDIS_HOST, REDIS_PORT, STORE_MODEL_IN_DB=True, LITELLM_LOCAL_MODEL_COST_MAP=True, and PROMETHEUS_MULTIPROC_DIR per process.

model_list:
  - model_name: gpt-6.2-sol
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: os.environ/OPENAI_API_KEY
  - model_name: gpt-6.2-astra
    litellm_params:
      model: openai/gpt-6.2-astra
      api_key: os.environ/OPENAI_API_KEY
  - model_name: claude-haiku-5-5
    litellm_params:
      model: anthropic/claude-haiku-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: gpt-6.2-sol-drop-summary
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: os.environ/OPENAI_API_KEY
      additional_drop_params: ["reasoning.summary"]
  - model_name: qa-primary
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: sk-qa-deliberately-invalid
    model_info:
      id: qa-primary-broken
      allowed_fails: 1
      cooldown_time: 600
  - model_name: qa-backup
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: os.environ/OPENAI_API_KEY
    model_info:
      id: qa-backup-ok
  - model_name: qwen3-rerank
    litellm_params:
      model: dashscope/qwen3-rerank
      api_key: os.environ/DASHSCOPE_API_KEY
      api_base: os.environ/DASHSCOPE_API_BASE

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  coordination_redis:
    host: os.environ/REDIS_HOST
    port: os.environ/REDIS_PORT

litellm_settings:
  drop_params: true
  callbacks: ["prometheus"]

router_settings:
  redis_host: os.environ/REDIS_HOST
  redis_port: os.environ/REDIS_PORT
  num_retries: 0
  fallbacks: [{"qa-primary": ["qa-backup"]}]

The client is cases.sh, run per leg with P and Q set to the two proxies and MK to the master key. It prints every command from the same string it runs (printf '$ %s\n' "$cmd"; eval "$cmd"). Full raw output of both legs is in the gist.

Case Before After
/v2/key/info, 3 keys and 1 missing 3 rows, no token 3 rows, no token
/v2/key/info as key owner own key only own key only
Streaming chat, fast and cost paths usage, then [DONE] same
Streaming /v1/responses, OpenAI and Anthropic 9 events, pong same
Nested additional_drop_params summary dropped summary dropped
Fallback after cooldown 6 of 6 from backup 6 of 6 from backup
Cooldown counters 2 fails, 1 cooldown 2 fails, 1 cooldown
/metrics series and labels 55, hash 5ea32bc3 55, hash 5ea32bc3
Team callback routes 200/403/401/404/400 same codes
/key/bulk_update 1 updated, 1 not found same
/v2/model/info sortBy 10 orders, bad order 400 same
CLI and client SDK all commands work same
DashScope rerank 200 200
Bundled cost map 7100 rows equals json.loads

Headline case: /v2/key/info on a DB-backed proxy

  1. Create keys qa-user-key (user qa-user), qa-mmb (team key with a model_max_budget) and qa-bl (with budget_limits)
  2. Spend on qa-mmb and qa-bl with streaming calls
  3. POST /v2/key/info for all three keys plus a missing one, as admin, through Q
  4. The same route as qa-user-key, and for the missing key alone

On both commits the admin call returns the three keys without a token field, with model_max_budget_usage and budget_limits_usage filled in, the owner sees only its own key, and the missing key returns info: [].

POST /v2/key/info output, before and after

Before (a1df18d)

$ sleep 20
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/spend/logs?api_key=sk-qa-mmb-0000002" -H "Authorization: Bearer $MK" | jq -c 'if type == "array" then [.[] | {model, call_type, spend_positive: (.spend > 0), total_tokens}] else . end'
HTTP 200
[{"model":"openai/gpt-6.2-sol","call_type":"acompletion","spend_positive":true,"total_tokens":15}]
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$Q/v2/key/info" -H "Authorization: Bearer $MK" -H "$J" -d '{"keys":["sk-qa-user-000001","sk-qa-mmb-0000002","sk-qa-bl-00000003","sk-qa-missing-9999"]}' | jq -c '.info[] | {key_alias, user_id, team_id, has_token: has("token"), model_max_budget, model_max_budget_usage: (.model_max_budget_usage // null | if . == null then null else with_entries(.value |= keys) end), budget_limits: [.budget_limits[]? | {budget_duration, max_budget}], budget_limits_usage: (.budget_limits_usage // null | if . == null then null else with_entries(.value |= keys) end), spend_positive: ((.spend // 0) > 0)}'
HTTP 200
{"key_alias":"qa-mmb","user_id":null,"team_id":"qa-team","has_token":false,"model_max_budget":{"gpt-6.2-sol":{"max_budget":1.0,"budget_duration":"1d"}},"model_max_budget_usage":{"gpt-6.2-sol":["budget_limit","budget_reset_at","current_spend","time_period"]},"budget_limits":[],"budget_limits_usage":null,"spend_positive":true}
{"key_alias":"qa-bl","user_id":null,"team_id":null,"has_token":false,"model_max_budget":{},"model_max_budget_usage":null,"budget_limits":[{"budget_duration":"1d","max_budget":2.0}],"budget_limits_usage":{"1d":["current_spend"]},"spend_positive":true}
{"key_alias":"qa-user-key","user_id":"qa-user","team_id":null,"has_token":false,"model_max_budget":{},"model_max_budget_usage":null,"budget_limits":[],"budget_limits_usage":null,"spend_positive":false}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/v2/key/info" -H "Authorization: Bearer sk-qa-user-000001" -H "$J" -d '{"keys":["sk-qa-user-000001","sk-qa-mmb-0000002"]}' | jq -c '[.info[] | .key_alias]'
HTTP 200
["qa-user-key"]
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/v2/key/info" -H "Authorization: Bearer $MK" -H "$J" -d '{"keys":["sk-qa-missing-9999"]}' | jq -c '{key: (.key | length), info}'
HTTP 200
{"key":1,"info":[]}

After (c66f8a4)

$ sleep 20
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/spend/logs?api_key=sk-qa-mmb-0000002" -H "Authorization: Bearer $MK" | jq -c 'if type == "array" then [.[] | {model, call_type, spend_positive: (.spend > 0), total_tokens}] else . end'
HTTP 200
[{"model":"openai/gpt-6.2-sol","call_type":"acompletion","spend_positive":true,"total_tokens":15}]
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$Q/v2/key/info" -H "Authorization: Bearer $MK" -H "$J" -d '{"keys":["sk-qa-user-000001","sk-qa-mmb-0000002","sk-qa-bl-00000003","sk-qa-missing-9999"]}' | jq -c '.info[] | {key_alias, user_id, team_id, has_token: has("token"), model_max_budget, model_max_budget_usage: (.model_max_budget_usage // null | if . == null then null else with_entries(.value |= keys) end), budget_limits: [.budget_limits[]? | {budget_duration, max_budget}], budget_limits_usage: (.budget_limits_usage // null | if . == null then null else with_entries(.value |= keys) end), spend_positive: ((.spend // 0) > 0)}'
HTTP 200
{"key_alias":"qa-mmb","user_id":null,"team_id":"qa-team","has_token":false,"model_max_budget":{"gpt-6.2-sol":{"max_budget":1.0,"budget_duration":"1d"}},"model_max_budget_usage":{"gpt-6.2-sol":["budget_limit","budget_reset_at","current_spend","time_period"]},"budget_limits":[],"budget_limits_usage":null,"spend_positive":true}
{"key_alias":"qa-bl","user_id":null,"team_id":null,"has_token":false,"model_max_budget":{},"model_max_budget_usage":null,"budget_limits":[{"budget_duration":"1d","max_budget":2.0}],"budget_limits_usage":{"1d":["current_spend"]},"spend_positive":true}
{"key_alias":"qa-user-key","user_id":"qa-user","team_id":null,"has_token":false,"model_max_budget":{},"model_max_budget_usage":null,"budget_limits":[],"budget_limits_usage":null,"spend_positive":false}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/v2/key/info" -H "Authorization: Bearer sk-qa-user-000001" -H "$J" -d '{"keys":["sk-qa-user-000001","sk-qa-mmb-0000002"]}' | jq -c '[.info[] | .key_alias]'
HTTP 200
["qa-user-key"]
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/v2/key/info" -H "Authorization: Bearer $MK" -H "$J" -d '{"keys":["sk-qa-missing-9999"]}' | jq -c '{key: (.key | length), info}'
HTTP 200
{"key":1,"info":[]}
Setup (team, internal user, three keys)

After (c66f8a4)

$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/new" -H "Authorization: Bearer $MK" -H "$J" -d '{"team_id":"qa-team","team_alias":"qa-team"}' | jq -c '{team_id, team_alias}'
HTTP 200
{"team_id":"qa-team","team_alias":"qa-team"}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/user/new" -H "Authorization: Bearer $MK" -H "$J" -d '{"user_id":"qa-user","user_role":"internal_user"}' | jq -c '{user_id, user_role}'
HTTP 200
{"user_id":"qa-user","user_role":"internal_user"}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/key/generate" -H "Authorization: Bearer $MK" -H "$J" -d '{"key":"sk-qa-user-000001","key_alias":"qa-user-key","user_id":"qa-user"}' | jq -c '{key_alias, user_id, team_id}'
HTTP 200
{"key_alias":"qa-user-key","user_id":"qa-user","team_id":null}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/key/generate" -H "Authorization: Bearer $MK" -H "$J" -d '{"key":"sk-qa-mmb-0000002","key_alias":"qa-mmb","team_id":"qa-team","model_max_budget":{"gpt-6.2-sol":{"max_budget":1.0,"budget_duration":"1d"}}}' | jq -c '{key_alias, team_id, model_max_budget}'
HTTP 200
{"key_alias":"qa-mmb","team_id":"qa-team","model_max_budget":{"gpt-6.2-sol":{"max_budget":1.0,"budget_duration":"1d"}}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/key/generate" -H "Authorization: Bearer $MK" -H "$J" -d '{"key":"sk-qa-bl-00000003","key_alias":"qa-bl","budget_limits":[{"budget_duration":"1d","max_budget":2.0}]}' | jq -c '{key_alias, budget_limits}'
HTTP 200
{"key_alias":"qa-bl","budget_limits":[{"budget_duration":"1d","max_budget":2.0,"reset_at":"2026-11-23T00:00:00Z","window_start":"2026-11-22T00:00:00Z"}]}

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

Team callbacks: POST, GET, disable_logging, DELETE, unknown team

After (c66f8a4)

$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/qa-team/callback" -H "Authorization: Bearer $MK" -H "$J" -d '{"callback_name":"langfuse","callback_type":"success","callback_vars":{"langfuse_public_key":"pk-lf-qa","langfuse_secret_key":"sk-lf-qa","langfuse_host":"https://us.cloud.langfuse.com"}}' | jq -c .
HTTP 200
{"status":"success","data":{"team_id":"qa-team","team_alias":"qa-team","organization_id":null,"object_permission_id":null,"admins":[],"members":[],"members_with_roles":[{"role":"admin","user_id":"default_user_id","user_email":null}],"metadata":{"logging":[{"callback_name":"langfuse","callback_type":"success","callback_vars":{"langfuse_host":"https://us.cloud.langfuse.com","langfuse_public_key":"litellm_enc::71FR6Fhxe3RQ0XNTdVfMfYTSW7di8ENcduUSz_W1d3dsirzIthhc-neYAXAphIlx","langfuse_secret_key":"litellm_enc::zqYBS4ComPlUNCWdjyD_HNKY-9nnjUpJbt5r35WFpYJ2PWxUIYyD0xU5uzFZu9Jg"}}]},"max_budget":null,"soft_budget":null,"spend":0.0,"models":[],"max_parallel_requests":null,"tpm_limit":null,"rpm_limit":null,"tpd_limit":null,"budget_duration":null,"budget_reset_at":null,"blocked":false,"created_at":"2026-11-22T23:51:34.648000Z","updated_at":"2026-11-22T23:51:35.208000Z","model_spend":{},"model_max_budget":{},"router_settings":{},"team_member_permissions":[],"access_group_ids":[],"policies":[],"default_team_member_models":[],"budget_limits":null,"model_id":null,"allow_team_guardrail_config":false,"litellm_organization_table":null,"litellm_model_table":null,"object_permission":null,"projects":null}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/team/qa-team/callback" -H "Authorization: Bearer $MK" | jq -c .
HTTP 200
{"status":"success","data":{"team_id":"qa-team","success_callbacks":["langfuse"],"failure_callbacks":[],"callback_vars":{"langfuse_host":"https://us.cloud.langfuse.com","langfuse_public_key":"***REDACTED***","langfuse_secret_key":"***REDACTED***"}}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/team/qa-team/callback" -H "Authorization: Bearer sk-qa-user-000001" | jq -c .
HTTP 403
{"detail":"You do not have access to this team"}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/qa-team/callback" -H "Authorization: Bearer sk-qa-user-000001" -H "$J" -d '{"callback_name":"langfuse","callback_type":"success","callback_vars":{"langfuse_public_key":"pk-lf-x","langfuse_secret_key":"sk-lf-x"}}' | jq -c .
HTTP 403
{"detail":"You do not have access to this team"}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/qa-team/disable_logging" -H "Authorization: Bearer sk-qa-user-000001" | jq -c .
HTTP 401
{"error":{"message":"Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/team/qa-team/disable_logging. Your role=internal_user. Your user_id=*******","type":"auth_error","param":null,"code":"401"}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/qa-team/disable_logging" -H "Authorization: Bearer $MK" | jq -c .
HTTP 200
{"status":"success","message":"Logging disabled for team qa-team","data":{"team_id":"qa-team","success_callbacks":[],"failure_callbacks":[]}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/team/qa-team/callback" -H "Authorization: Bearer $MK" | jq -c .
HTTP 200
{"status":"success","data":{"team_id":"qa-team","success_callbacks":[],"failure_callbacks":[],"callback_vars":{}}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X DELETE "$P/team/qa-team/callback/langfuse" -H "Authorization: Bearer $MK" | jq -c .
HTTP 404
{"detail":{"error":"callback_name = langfuse is not registered for team_id = qa-team."}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/team/qa-team/callback" -H "Authorization: Bearer $MK" | jq -c .
HTTP 200
{"status":"success","data":{"team_id":"qa-team","success_callbacks":[],"failure_callbacks":[],"callback_vars":{}}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$P/team/qa-missing/callback" -H "Authorization: Bearer $MK" | jq -c .
HTTP 404
{"detail":{"error":"Team id = qa-missing does not exist."}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/qa-missing/callback" -H "Authorization: Bearer $MK" -H "$J" -d '{"callback_name":"langfuse","callback_type":"success","callback_vars":{"langfuse_public_key":"pk-lf-qa","langfuse_secret_key":"sk-lf-qa"}}' | jq -c .
HTTP 400
{"detail":{"error":"Team id = qa-missing does not exist."}}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/team/qa-missing/disable_logging" -H "Authorization: Bearer $MK" | jq -c .
HTTP 404
{"detail":{"error":"Team id = qa-missing does not exist."}}

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

Streaming /v1/chat/completions

After (c66f8a4)

$ curl -sS -N "$P/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"gpt-6.2-sol","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | awk 'NF' > $T/chat1.sse; grep -c '^data: ' $T/chat1.sse; head -1 $T/chat1.sse | cut -c1-160; tail -2 $T/chat1.sse | cut -c1-400
5
data: {"id":"chatcmpl-EnBdIPy17fID99zCAGDdWLjxTOOa4","created":1795391497,"model":"gpt-6.2-sol","object":"chat.completion.chunk","choices":[{"index":0,"delta":{
data: {"id":"chatcmpl-EnBdIPy17fID99zCAGDdWLjxTOOa4","created":1795391497,"model":"gpt-6.2-sol","object":"chat.completion.chunk","choices":[],"usage":{"completion_tokens":4,"prompt_tokens":11,"total_tokens":15,"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,
data: [DONE]
$ curl -sS -N "$Q/v1/chat/completions" -H "Authorization: Bearer sk-qa-mmb-0000002" -H "$J" -H 'x-litellm-include-cost-in-streaming-usage: true' -d '{"model":"gpt-6.2-sol","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | awk 'NF' > $T/chat2.sse; grep -c '^data: ' $T/chat2.sse; tail -2 $T/chat2.sse | cut -c1-500
5
data: {"id":"chatcmpl-EnBdJUDs6Y70pZUfM8Ilt82OpODPx","created":1795391498,"model":"gpt-6.2-sol","object":"chat.completion.chunk","choices":[],"usage":{"completion_tokens":4,"prompt_tokens":11,"total_tokens":15,"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,"cache_write_tokens":0,"cache_creation_tokens":0},"cost":0.000062},"service_tier":"default"}
data: [DONE]
$ curl -sS -N "$P/v1/chat/completions" -H "Authorization: Bearer sk-qa-bl-00000003" -H "$J" -H 'x-litellm-include-cost-in-streaming-usage: true' -d '{"model":"claude-haiku-5-5","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | awk 'NF' > $T/chat3.sse; grep -c '^data: ' $T/chat3.sse; tail -2 $T/chat3.sse | cut -c1-500
4
data: {"id":"chatcmpl-78581dda-7929-4734-a5d9-89c0e1ef7c41","created":1795391500,"model":"claude-haiku-5-5","object":"chat.completion.chunk","choices":[],"usage":{"completion_tokens":4,"prompt_tokens":18,"total_tokens":22,"completion_tokens_details":{"reasoning_tokens":0,"text_tokens":4},"prompt_tokens_details":{"cached_tokens":0,"text_tokens":18,"cache_write_tokens":0,"cache_creation_tokens":0,"cache_creation_token_details":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0}},"cost":3
data: [DONE]

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

Streaming /v1/responses

After (c66f8a4)

$ curl -sS -N "$P/v1/responses" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"gpt-6.2-sol","stream":true,"input":"Reply with exactly: pong"}' > $T/resp1.sse; grep '^event:' $T/resp1.sse | uniq -c; grep -A1 '^event: response.completed' $T/resp1.sse | tail -1 | sed 's/^data: //' | jq -c '{status: .response.status, text: .response.output[-1].content[0].text}'
      1 event: response.created
      1 event: response.in_progress
      1 event: response.output_item.added
      1 event: response.content_part.added
      1 event: response.output_text.delta
      1 event: response.output_text.done
      1 event: response.content_part.done
      1 event: response.output_item.done
      1 event: response.completed
{"status":"completed","text":"pong"}
$ curl -sS -N "$Q/v1/responses" -H "Authorization: Bearer $MK" -H "$J" -H 'x-litellm-include-cost-in-streaming-usage: true' -d '{"model":"claude-haiku-5-5","stream":true,"instructions":"Be terse.","temperature":0.2,"input":"Reply with exactly: pong"}' > $T/resp2.sse; grep '^event:' $T/resp2.sse | uniq -c; grep -A1 '^event: response.created' $T/resp2.sse | tail -1 | sed 's/^data: //' | jq -c '.response | {object, status, model, instructions, temperature, store}'; grep -A1 '^event: response.completed' $T/resp2.sse | tail -1 | sed 's/^data: //' | jq -c '{status: .response.status, text: .response.output[-1].content[0].text}'
      1 event: response.created
      1 event: response.in_progress
      1 event: response.output_item.added
      1 event: response.content_part.added
      1 event: response.output_text.delta
      1 event: response.output_text.done
      1 event: response.content_part.done
      1 event: response.output_item.done
      1 event: response.completed
{"object":"response","status":"in_progress","model":"claude-haiku-5-5","instructions":"Be terse.","temperature":0.2,"store":true}
{"status":"completed","text":"pong"}
$ curl -sS -N "$P/v1/responses" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"gpt-6.2-sol","stream":true,"reasoning":{"effort":"low","summary":"auto"},"input":"Reply with exactly: pong"}' > $T/resp3.sse; grep -A1 '^event: response.completed' $T/resp3.sse | tail -1 | sed 's/^data: //' | jq -c '{status: .response.status, reasoning: .response.reasoning}'
{"status":"completed","reasoning":{"effort":"low","summary":"detailed","context":"all_turns","mode":"standard"}}
$ curl -sS -N "$Q/v1/responses" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"gpt-6.2-sol-drop-summary","stream":true,"reasoning":{"effort":"low","summary":"auto"},"input":"Reply with exactly: pong"}' > $T/resp4.sse; grep -A1 '^event: response.completed' $T/resp4.sse | tail -1 | sed 's/^data: //' | jq -c '{status: .response.status, reasoning: .response.reasoning}'
{"status":"completed","reasoning":{"effort":"low","context":"all_turns","summary":null,"mode":"standard"}}

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

Fallback after cooldown, plus /metrics deployment counters

After (c66f8a4)

$ curl -sS -o $T/fb.json -D - -w 'time %{time_total}s\n' "$P/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qa-primary","messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | grep -iE '^HTTP|^x-litellm-model-id|^x-litellm-attempted-fallbacks|^time'; jq -c '{model, content: .choices[0].message.content}' $T/fb.json
HTTP/1.1 200 OK
x-litellm-model-id: qa-backup-ok
x-litellm-attempted-fallbacks: 1
time 1.211754s
{"model":"gpt-6.2-sol","content":"pong"}
$ curl -sS -o $T/fb.json -D - -w 'time %{time_total}s\n' "$Q/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qa-primary","messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | grep -iE '^HTTP|^x-litellm-model-id|^x-litellm-attempted-fallbacks|^time'; jq -c '{model, content: .choices[0].message.content}' $T/fb.json
HTTP/1.1 200 OK
x-litellm-model-id: qa-backup-ok
x-litellm-attempted-fallbacks: 1
time 1.010725s
{"model":"gpt-6.2-sol","content":"pong"}
$ curl -sS -o $T/fb.json -D - -w 'time %{time_total}s\n' "$P/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qa-primary","messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | grep -iE '^HTTP|^x-litellm-model-id|^x-litellm-attempted-fallbacks|^time'; jq -c '{model, content: .choices[0].message.content}' $T/fb.json
HTTP/1.1 200 OK
x-litellm-model-id: qa-backup-ok
x-litellm-attempted-fallbacks: 1
time 0.932385s
{"model":"gpt-6.2-sol","content":"pong"}
$ curl -sS -o $T/fb.json -D - -w 'time %{time_total}s\n' "$Q/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qa-primary","messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | grep -iE '^HTTP|^x-litellm-model-id|^x-litellm-attempted-fallbacks|^time'; jq -c '{model, content: .choices[0].message.content}' $T/fb.json
HTTP/1.1 200 OK
x-litellm-model-id: qa-backup-ok
x-litellm-attempted-fallbacks: 1
time 0.802773s
{"model":"gpt-6.2-sol","content":"pong"}
$ curl -sS -o $T/fb.json -D - -w 'time %{time_total}s\n' "$P/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qa-primary","messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | grep -iE '^HTTP|^x-litellm-model-id|^x-litellm-attempted-fallbacks|^time'; jq -c '{model, content: .choices[0].message.content}' $T/fb.json
HTTP/1.1 200 OK
x-litellm-model-id: qa-backup-ok
x-litellm-attempted-fallbacks: 1
time 1.022069s
{"model":"gpt-6.2-sol","content":"pong"}
$ curl -sS -o $T/fb.json -D - -w 'time %{time_total}s\n' "$Q/v1/chat/completions" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qa-primary","messages":[{"role":"user","content":"Reply with exactly: pong"}]}' | grep -iE '^HTTP|^x-litellm-model-id|^x-litellm-attempted-fallbacks|^time'; jq -c '{model, content: .choices[0].message.content}' $T/fb.json
HTTP/1.1 200 OK
x-litellm-model-id: qa-backup-ok
x-litellm-attempted-fallbacks: 1
time 0.902781s
{"model":"gpt-6.2-sol","content":"pong"}
$ for u in "$P" "$Q"; do echo "[$u]"; curl -sS "$u/metrics/" -H "Authorization: Bearer $MK" | grep -E '^litellm_deployment_(cooled_down|failure_responses|successful_fallbacks)_total' | perl -ne 'my ($n)=/^(\w+)/; my ($m)=/model_id="([^"]*)"/; my ($f)=/fallback_model="([^"]*)"/; my ($v)=/ (\S+)$/; print join(" ", grep { defined && length } ($n, $m ? "model_id=$m" : undef, $f ? "fallback_model=$f" : undef, $v)), "\n"'; done
[http://127.0.0.1:31232]
litellm_deployment_failure_responses_total model_id=qa-primary-broken 1.0
litellm_deployment_failure_responses_total 2.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 1.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 2.0
[http://127.0.0.1:20811]
litellm_deployment_failure_responses_total model_id=qa-primary-broken 1.0
litellm_deployment_failure_responses_total 1.0
litellm_deployment_failure_responses_total 1.0
litellm_deployment_cooled_down_total model_id=qa-primary-broken 1.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 1.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 2.0

Before (a1df18d), counters only

$ for u in "$P" "$Q"; do echo "[$u]"; curl -sS "$u/metrics/" -H "Authorization: Bearer $MK" | grep -E '^litellm_deployment_(cooled_down|failure_responses|successful_fallbacks)_total' | perl -ne 'my ($n)=/^(\w+)/; my ($m)=/model_id="([^"]*)"/; my ($f)=/fallback_model="([^"]*)"/; my ($v)=/ (\S+)$/; print join(" ", grep { defined && length } ($n, $m ? "model_id=$m" : undef, $f ? "fallback_model=$f" : undef, $v)), "\n"'; done
[http://127.0.0.1:29711]
litellm_deployment_failure_responses_total 1.0
litellm_deployment_failure_responses_total model_id=qa-primary-broken 1.0
litellm_deployment_failure_responses_total 1.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 2.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 1.0
[http://127.0.0.1:23974]
litellm_deployment_failure_responses_total 1.0
litellm_deployment_failure_responses_total 1.0
litellm_deployment_failure_responses_total model_id=qa-primary-broken 1.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 2.0
litellm_deployment_successful_fallbacks_total model_id=None fallback_model=qa-backup 1.0
litellm_deployment_cooled_down_total model_id=qa-primary-broken 1.0
GET /metrics series and label names

After (c66f8a4)

$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$P/metrics/" -H "Authorization: Bearer $MK" | grep -v '^#' | sed -E 's/="[^"]*"//g; s/ [^ ]+$//' | sort -u > $T/metrics.txt; wc -l < $T/metrics.txt; grep -E '^litellm_(requests_metric_total|deployment_cooled_down_total|spend_metric_total)' $T/metrics.txt; sha256sum $T/metrics.txt | cut -c1-16
HTTP 200
55
litellm_requests_metric_total{api_key_alias,api_provider,client_ip,end_user,hashed_api_key,model,model_id,org_alias,org_id,requested_model,team,team_alias,user,user_agent,user_email}
litellm_spend_metric_total{api_key_alias,api_provider,client_ip,end_user,hashed_api_key,model,model_id,org_alias,org_id,requested_model,service_tier,team,team_alias,user,user_agent,user_email}
5ea32bc3178669bf

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

DashScope /v1/rerank

After (c66f8a4)

$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$P/v1/rerank" -H "Authorization: Bearer $MK" -H "$J" -d '{"model":"qwen3-rerank","query":"What is the capital of France?","documents":["Paris is the capital of France.","Berlin is the capital of Germany."],"top_n":2}' | jq -c '{results: [.results[] | {index, relevance_score}]}'
HTTP 200
{"results":[{"index":0,"relevance_score":0.8244535807036237},{"index":1,"relevance_score":0.2604633376691415}]}

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

POST /key/bulk_update

After (c66f8a4)

$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/key/bulk_update" -H "Authorization: Bearer $MK" -H "$J" -d '{"keys":[{"key":"sk-qa-bl-00000003","max_budget":9.5,"tags":["qa-bulk"]},{"key":"sk-qa-missing-9999","max_budget":1}]}' | jq -c '{total_requested, successful: [.successful_updates[] | {key_alias: .key_info.key_alias, max_budget: .key_info.max_budget, tags: .key_info.tags, has_token: (.key_info | has("token"))}], failed: [.failed_updates[] | {failed_reason}]}'
HTTP 200
{"total_requested":2,"successful":[{"key_alias":"qa-bl","max_budget":9.5,"tags":null,"has_token":false}],"failed":[{"failed_reason":"Key not found."}]}
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/key/info?key=sk-qa-bl-00000003" -H "Authorization: Bearer $MK" | jq -c '.info | {key_alias, max_budget, tags}'
HTTP 200
{"key_alias":"qa-bl","max_budget":9.5,"tags":null}

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

/v2/model/info sortBy and /model/info pricing

After (c66f8a4)

$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/model/new" -H "Authorization: Bearer $MK" -H "$J" -d '{"model_name":"db-zeta","litellm_params":{"model":"openai/gpt-6.2-sol","input_cost_per_token":0.00003,"output_cost_per_token":0.00006}}' | jq -c '{model_name}'
HTTP 200
{"model_name":"db-zeta"}
$ sleep 2
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' -X POST "$P/model/new" -H "Authorization: Bearer $MK" -H "$J" -d '{"model_name":"db-alpha","litellm_params":{"model":"anthropic/claude-haiku-5-5"}}' | jq -c '{model_name}'
HTTP 200
{"model_name":"db-alpha"}
$ sleep 5
$ for s in model_name created_at updated_at costs status; do for o in asc desc; do printf '%s %s ' $s $o; curl -sS "$Q/v2/model/info?sortBy=$s&sortOrder=$o&size=50" -H "Authorization: Bearer $MK" | jq -c '[.data[].model_name]'; done; done
model_name asc ["claude-haiku-5-5","db-alpha","db-zeta","gpt-6.2-astra","gpt-6.2-sol","gpt-6.2-sol-drop-summary","qa-backup","qa-primary","qwen3-rerank"]
model_name desc ["qwen3-rerank","qa-primary","qa-backup","gpt-6.2-sol-drop-summary","gpt-6.2-sol","gpt-6.2-astra","db-zeta","db-alpha","claude-haiku-5-5"]
created_at asc ["db-zeta","db-alpha","gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank"]
created_at desc ["db-alpha","db-zeta","gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank"]
updated_at asc ["db-zeta","db-alpha","gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank"]
updated_at desc ["db-alpha","db-zeta","gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank"]
costs asc ["claude-haiku-5-5","db-alpha","gpt-6.2-sol","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","gpt-6.2-astra","db-zeta","qwen3-rerank"]
costs desc ["db-zeta","gpt-6.2-astra","gpt-6.2-sol","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","claude-haiku-5-5","db-alpha","qwen3-rerank"]
status asc ["gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank","db-zeta","db-alpha"]
status desc ["db-zeta","db-alpha","gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank"]
$ curl -sS -w '%{stderr}HTTP %{http_code}\n' "$Q/v2/model/info?sortBy=costs&sortOrder=sideways" -H "Authorization: Bearer $MK" | jq -c .
HTTP 400
{"detail":"Invalid sortOrder: sideways. Must be 'asc' or 'desc'"}
$ curl -sS "$P/model/info" -H "Authorization: Bearer $MK" | jq -c '[.data[] | {model_name, i: .model_info.input_cost_per_token, o: .model_info.output_cost_per_token}]'
[{"model_name":"gpt-6.2-sol","i":0.000002,"o":0.00001},{"model_name":"gpt-6.2-astra","i":0.000008,"o":0.00004},{"model_name":"claude-haiku-5-5","i":1E-7,"o":5E-7},{"model_name":"gpt-6.2-sol-drop-summary","i":0.000002,"o":0.00001},{"model_name":"qa-primary","i":0.000002,"o":0.00001},{"model_name":"qa-backup","i":0.000002,"o":0.00001},{"model_name":"qwen3-rerank","i":null,"o":null},{"model_name":"db-zeta","i":0.00003,"o":0.00006},{"model_name":"db-alpha","i":1E-7,"o":5E-7}]

Before (a1df18d) printed the same lines, apart from response ids, timestamps, rerank scores and ciphertext. It is in the gist.

litellm-proxy CLI and client SDK calls

After (c66f8a4)

$ export HOME=$(mktemp -d) LITELLM_PROXY_URL="$P" LITELLM_PROXY_API_KEY="$MK"
$ .venv/bin/litellm-proxy credentials create qa-cred --info '{"custom_llm_provider":"openai"}' --values '{"api_key":"sk-qa-dummy"}' | jq -c '{credential_name}'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
{"credential_name":null}
$ .venv/bin/litellm-proxy credentials list --format json | jq -c '[.credentials[] | .credential_name]'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
["qa-cred"]
$ sleep 15
$ .venv/bin/litellm-proxy credentials list --format json | jq -c '[.credentials[] | .credential_name]'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
["qa-cred"]
$ .venv/bin/litellm-proxy models list --format json | jq -c '[.[].id]'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
["gpt-6.2-sol","gpt-6.2-astra","claude-haiku-5-5","gpt-6.2-sol-drop-summary","qa-primary","qa-backup","qwen3-rerank","db-zeta","db-alpha"]
$ .venv/bin/litellm-proxy models info --format json | jq -c '[.[] | .model_name] | sort'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
["claude-haiku-5-5","db-alpha","db-zeta","gpt-6.2-astra","gpt-6.2-sol","gpt-6.2-sol-drop-summary","qa-backup","qa-primary","qwen3-rerank"]
$ .venv/bin/litellm-proxy model-groups list --format json | jq -c '[.[].model_group] | sort'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
["claude-haiku-5-5","db-alpha","db-zeta","gpt-6.2-astra","gpt-6.2-sol","gpt-6.2-sol-drop-summary","qa-backup","qa-primary","qwen3-rerank"]
$ .venv/bin/litellm-proxy keys list --format json | jq -c '{total_count, keys: (.keys | length)}'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
{"total_count":4,"keys":4}
$ .venv/bin/litellm-proxy teams list | grep -c qa-team
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
1
$ .venv/bin/litellm-proxy --api-key sk-qa-user-000001 teams available; echo "exit $?"
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
No available teams to join.
exit 0
$ .venv/bin/litellm-proxy users list | grep -c qa-user
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
1
$ .venv/bin/litellm-proxy users get --id qa-user | jq -c '{user_id, role: .user_info.user_role, keys: (.keys | length), teams: .teams}'
The `litellm-proxy` command is deprecated and will be removed in a future release; run `lite` instead, it takes the same commands and options.
{"user_id":"qa-user","role":"internal_user","keys":2,"teams":[]}
$ printf 'Reply with exactly: pong\n/quit\n' | .venv/bin/litellm-proxy chat claude-haiku-5-5 2>&1 | tail -6

You: 
Assistant:
pong

You: Chat session ended.

Before (a1df18d), credentials lines only

$ .venv/bin/litellm-proxy credentials create qa-cred --info '{"custom_llm_provider":"openai"}' --values '{"api_key":"sk-qa-dummy"}' | jq -c '{credential_name}'
{"credential_name":null}
$ .venv/bin/litellm-proxy credentials list --format json | jq -c '[.credentials[] | .credential_name]'
[]
$ sleep 15
$ .venv/bin/litellm-proxy credentials list --format json | jq -c '[.credentials[] | .credential_name]'
Focused check: bundled cost map load

Before (a1df18d) and after (c66f8a4) printed the same

$ LITELLM_LOCAL_MODEL_COST_MAP=True .venv/bin/python - <<EOF (costmap_check.py)
type=dict rows=7100 equals_json_loads=True
key_order_equal=True
bundled_sha256=8335a7bdfaeece5e
loaded_sha256=a114491ac1029d2f

This is focused evidence, not e2e. The loader now parses with a pydantic TypeAdapter. The proxy reads it only for the bundled model count and the Bedrock and Vertex Lyria fallbacks, which this run could not reach live, so this check stands in for them.

The SageMaker, Vigil Guard, NLP Cloud and FIPS changes ran only in their unit suites (1334 passed at c66f8a4), since the rig has no setup for them.

Raw logs, the case script and the config are in this gist.

/live-pr-risk at e74b46f

Base a527f1a and head e74b46f ran on the GCE rig with recorders in front of OpenAI and Anthropic. The 40 cells matched on status, body shape, the request sent upstream and the spend row, apart from ids, nonces and timestamps. They covered nested drops and previous_response_id turns on /v1/responses, the Anthropic bridge with streaming and tools, websocket responses, team callback add, get, disable and delete, /user/info, and a live Deep Agents run. The compression merge resolution sent the same [thinking, text, tool_use] follow-up on both. The management, observability and security integration lanes passed on head (455, 6 and 28 tests). In-process checks of the cost map load, _sort_models, budget_limit_windows and Vigil Guard matched too

The one difference is that AgenticLoopRequestPatch(messages=...) now rejects an iterable that is not a sequence, like a generator, where base turned it into a list. Every producer in the repo passes a list. Code interpreter, Vigil Guard, NLP Cloud, headroom and compresr had no live keys, and the FIPS seal stops at the same EVP_CIPHER_fetch call on both, since the box has no FIPS provider

Scripts and outputs are the 5-lpr-e74b46f8-* files in the gist

Type counts

Rule main this PR
reportAny 926 678
reportExplicitAny 212 202
basedpyright total 90353 90064

Measured by the type gate's whole-tree basedpyright run at 8d9afd4 against a1df18d, where no rule grew. legacy_spend_log_rows.py stays as main has it, since it is code-owned

Merge with main and test notes

Merge with main. Merging main at a1df18d conflicted in the app budget helper, which keeps main's app_budget_selection rename, and the budget limiter, which keeps both import lines. The merge commit also restores an import git dropped from the router cooldown handlers and regenerates the stale OpenAPI snapshot and dashboard schema.d.ts

Commit 8d9afd4. It returns the proxy client SDK and vector store types to main's code, gives two public fields read-only types, and copies websearch follow-up messages into plain dicts. Unit suites for those paths pass there (6866 passed), and a new test checks that a tuple of messages still reaches the follow-up call as a list.

Second merge with main. Commit e74b46f merges main at a527f1a. Only the compression interception handler conflicted. The merge keeps this PR's typed message dicts and adds the text blocks main now streams before the retrieval tool call, so the handler behaves as main does. Its unit tests pass at the merge, and make check and the code-quality scripts pass too.

Timing differences. The fallback case prints the same totals on both legs. The counter lines come out in a different order and split across label sets, because a skipped deployment's failure gets a random requested_model label on both commits. The CLI's first credentials list right after credentials create showed [] on one leg per run (after in an earlier run, before in this one). 15 seconds later both legs list qa-cred, so this is a short delay before the other worker sees the new credential, on both commits.

Tests. The cooldown test fixture reloaded litellm.proxy.proxy_server, which broke 14 live-session tests that ran after it in the same process. It no longer reloads the proxy server, which those tests never use

Type

🧹 Refactoring

Caveats (if any)

Low

  • AgenticLoopRequestPatch.messages and Responses metadata take read-only Sequence and Mapping types instead of Any
    • A typed caller passing a non-mapping now gets a type error, which is the point
    • At runtime a generator for messages now fails validation where base made it a list. Every producer in the repo passes a list
  • Some parameters and the streaming hooks' return types widen to object, like check_special_tokens(chunk) and budget_limit_windows
    • Their callers hold untyped chunk content or DB JSON, so a narrow type would only move a cast into each caller
  • Team callback settings, deepagents messages, Prometheus labels and /v2/key/info rows validate up front, and helpers like TypeAdapter(object) and NLP Cloud's open TypedDict splat only change a static type
    • The A/B and unit suites pass the same values, and dropping them brings the Anys back
  • SageMaker, Vigil Guard, NLP Cloud and FIPS paths ran only in unit suites and in-process checks
    • No live setup exists for them on the QA rig
  • The goal of removing 1,000 Anys was out of reach, since main holds 1,138 and this PR removes 258
    • The last two waves each netted 26, so the run stopped

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]
Low Risk
Changes are primarily type narrowing and optional validation at existing boundaries; the author reports no API or spend behavior differences in e2e and unit suites, with only minor caveats around stricter static types for some public TypedDict fields.

Overview
This PR tightens static typing across 35 files by swapping loose Any / concrete third‑party imports for object, Protocol, TypedDict, and pydantic.TypeAdapter validation at boundaries—without changing the intended runtime contract.

Harness & integrations: The Deep Agents handler now loads optional LangChain/LangGraph deps through require_attributes and validates converted history via _OPENAI_MESSAGES. Compression/websearch/agentic-loop paths build follow-up messages as explicit dict[str, object] copies, and AgenticLoopRequestPatch.messages accepts read-only mappings validated into a list.

Core paths: Bundled model cost JSON loads through a TypeAdapter; SageMaker streaming uses json_contains/concatenated on untyped chunks; NLP Cloud/DashScope responses and JWT cache reads are validated before use; logging failure cleanup reads _model_call_details_view.

Proxy: /v2/key/info, team callback CRUD, budget-usage builders, streaming chunk handling, MCP elicitation errors, model list sorting, and related hooks gain Protocol-shaped row/metadata access plus iter_items/has_attributes instead of blind dict/hasattr assumptions. Spend-log Rust builder passes named config fields instead of **config._asdict().

A new unit test asserts agentic-loop follow-ups still receive messages as a list when the patch supplies a tuple.

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

…20261121

# Conflicts:
#	litellm/proxy/hooks/model_max_budget_limiter.py
#	litellm/proxy/management_helpers/apps.py
…sts reloading proxy_server

The SDK list, info and stream helpers return Mapping, Sequence and JsonValue shapes validated by pydantic instead of bare object. The cooldown test fixture no longer reloads litellm.proxy.proxy_server, which swapped the FastAPI app under test_proxy_server's dependency overrides when both files shared a worker.
@veria-ai

veria-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 22, 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 replaces loose types with narrower annotations and existing typed helpers across 35 files. It also keeps follow-up messages as lists and removes an unnecessary proxy reload from cooldown tests.

No actionable issues were found. No previous review threads were supplied. Tests were not run during this review.

  • Key information keeps its access checks and budget details.
  • Team callback routes keep settings scoped to the selected team.
  • Streaming and Responses calls keep their existing payloads.
  • Provider and agent paths keep passing the same messages and results.
  • Shared proxy helpers keep their existing routing and data flows.

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

@mateo-berri mateo-berri changed the title refactor(typing): clear basedpyright Any errors across 40 files refactor(typing): clear basedpyright Any errors across 35 files Nov 23, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…20261121

# Conflicts:
#	litellm/integrations/compression_interception/handler.py
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

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 e74b46f. Configure here.

@mateo-berri mateo-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.

LGTM

@mateo-berri
mateo-berri merged commit 34d6cb3 into BerriAI:main Nov 24, 2026
68 checks passed
mateo-berri added a commit to rhea-tk/litellm that referenced this pull request Nov 24, 2026
Pass the provider-signed limit to the Rust row builder again after BerriAI#53599 spelled out its arguments, and record BerriAI#53405's two new golden rows with that config key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants