Skip to content

fix(caching): read the cache key's model group from the router's metadata for the call - #48917

Merged
mateo-berri merged 8 commits into
BerriAI:mainfrom
mika-lt:litellm_audit_44542
Oct 29, 2026
Merged

mateo-berri merged 8 commits into
BerriAI:mainfrom
mika-lt:litellm_audit_44542

Conversation

@mika-lt

@mika-lt mika-lt commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

#44542 keyed the response cache on the router's model group for /v1/responses and /v1/messages, but still read model_group and caching_groups from the caller's metadata first, so a caller could plant an answer in another group's cache entry. This follow-up reads both from the router's metadata for the call

Original

TLDR

Problem this solves:

How it solves it:

  • Read both from the router's metadata for the call
  • Add integration tests on all three endpoints
Decisions

On a routed call the cache reads model_group from the metadata whose model_info matches the call's own model_info. The router writes the chosen deployment's model_info into its own metadata and onto the call, so the match finds the router's metadata even when the other one also names a group, as when the auto router's classifier embedding forwards its parent's litellm_metadata. litellm_metadata is checked first, so a caller who copies their deployment's model_info into metadata still loses. A call with no match never went through a router, and it keeps main's lookup unchanged. Three other ways were possible. Reading litellm_metadata first everywhere, an earlier version of this PR, gave forwarded classifier calls the parent's group and changed keys for SDK calls outside the router. Reading only the bucket get_metadata_variable_name_from_kwargs picks broke SDK users who pass their own litellm_metadata to Router.acompletion. Stripping model_group from the caller's metadata would change what the proxy sends to OpenAI and Anthropic

On a routed call, caching groups come only from that matched source, because the router writes its own caching_groups there on every routed call, None when unset. Walking every source let a caller's metadata.caching_groups stand in when the router had none. Both lookups pass the group through str(), which gives the same key text main's f-string builds

User Flow

Before: a caller can choose the cached answer another model group's users get

  1. The admin turns on response caching and serves support-bot on gpt-5.6 and sales-bot on gpt-5.4-mini
  2. A caller limited to sales-bot sends POST https://litellm-domain/v1/responses with "model": "sales-bot", a question, and "metadata": {"model_group": "support-bot"}
  3. A support-bot user sends the same question to POST https://litellm-domain/v1/responses with "model": "support-bot"
  4. They get sales-bot's cached answer, and gpt-5.6 never sees it
  5. /v1/messages and "metadata": {"caching_groups": [...]} work the same way

After: the planted answer never reaches the other group

  1. The admin turns on response caching and serves support-bot on gpt-5.6 and sales-bot on gpt-5.4-mini
  2. A caller limited to sales-bot sends POST https://litellm-domain/v1/responses with "model": "sales-bot", a question, and "metadata": {"model_group": "support-bot"}
  3. A support-bot user sends the same question to POST https://litellm-domain/v1/responses with "model": "support-bot"
  4. They get a fresh answer from gpt-5.6, and their repeat comes from the cache
  5. Neither field changes another group's cached answers

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

Live QA PASS on real OpenAI and Anthropic, before at merge base a604c89059 and after at 35500573ec. Each leg runs two two-worker proxies sharing one Redis and database, and each key covers only its caller's groups

Endpoint Case Before After
responses Planted model_group Planted answer Own answer
responses Planted caching_groups Planted answer Own answer
messages Planted model_group Planted answer Own answer
messages Planted caching_groups Planted answer Own answer
chat Planted model_group Own answer Own answer
chat Planted caching_groups Own answer Own answer
responses Shared caching group Shared entry Shared entry
messages Shared caching group Shared entry Shared entry
chat Shared caching group Shared entry Shared entry
SDK chat Forwarded litellm_metadata Own answer, repeat cached Own answer, repeat cached
SDK embeddings Forwarded litellm_metadata Own vector, repeat cached Own vector, repeat cached
Config and client

A planted case plants through one proxy, asks as the other group through the second, then again through the first. A shared group case asks as each group in turn

model_list:
  - model_name: support-bot
    litellm_params:
      model: openai/gpt-5.6
      api_key: os.environ/OPENAI_API_KEY
  - model_name: sales-bot
    litellm_params:
      model: openai/gpt-5.4-mini
      api_key: os.environ/OPENAI_API_KEY
  - model_name: support-claude
    litellm_params:
      model: anthropic/claude-sonnet-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: sales-claude
    litellm_params:
      model: anthropic/claude-haiku-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: sales-bot-premium
    litellm_params:
      model: openai/gpt-5.6
      api_key: os.environ/OPENAI_API_KEY
  - model_name: sales-claude-premium
    litellm_params:
      model: anthropic/claude-sonnet-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: team-a
    litellm_params:
      model: openai/gpt-5.6
      api_key: os.environ/OPENAI_API_KEY
  - model_name: team-b
    litellm_params:
      model: openai/gpt-5.4-mini
      api_key: os.environ/OPENAI_API_KEY
  - model_name: team-a-claude
    litellm_params:
      model: anthropic/claude-sonnet-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: team-b-claude
    litellm_params:
      model: anthropic/claude-haiku-5-5
      api_key: os.environ/ANTHROPIC_API_KEY

router_settings:
  caching_groups: [["team-a", "team-b"], ["team-a-claude", "team-b-claude"]]

litellm_settings:
  cache: true
  cache_params:
    type: redis

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

The client is this script, run once per leg with the two proxy URLs read from the environment and the master key used only to create the three keys. ask prints the status line, the time, the start of the x-litellm-cache-key header, and the response's id, model and first 60 characters of text

set -u
A="$INTEGRATION_PROXY_URL"; B="$INTEGRATION_PEER_URL"; LEG="$1"
mint() {
  curl -sS "$A/key/generate" -H "Authorization: Bearer $INTEGRATION_MASTER_KEY" -H 'Content-Type: application/json' \
    -d "{\"models\": $1}" | python3 -c 'import json,sys; print(json.load(sys.stdin)["key"])'
}
SALES_KEY=$(mint '["sales-bot", "sales-claude"]')
SUPPORT_KEY=$(mint '["support-bot", "support-claude", "sales-bot-premium", "sales-claude-premium"]')
TEAM_KEY=$(mint '["team-a", "team-b", "team-a-claude", "team-b-claude"]')
NONCE="$(date +%s)-$LEG"
ask() {
  local key="$1" url="$2" route="$3" body="$4"
  local hdr; hdr="$(mktemp)"
  local start end out
  start=$(date +%s%3N)
  out=$(curl -sS -D "$hdr" "$url$route" -H "Authorization: Bearer $key" -H 'Content-Type: application/json' -d "$body")
  end=$(date +%s%3N)
  local ck; ck=$(grep -i '^x-litellm-cache-key:' "$hdr" | tr -d '\r' | cut -c1-40)
  local code; code=$(head -1 "$hdr" | tr -d '\r')
  printf '%s | %sms | %s\n' "$code" "$((end-start))" "${ck:-x-litellm-cache-key: (none)}"
  printf '%s' "$out" | python3 -c '
import json,sys
d=json.load(sys.stdin)
if "output" in d:
    t=[c.get("text") for o in d["output"] if o.get("type")=="message" for c in o.get("content",[])]
    print("id", d.get("id"), "| model", d.get("model"), "| text", (t[0] or "")[:60] if t else None)
elif "choices" in d:
    print("id", d.get("id"), "| model", d.get("model"), "| text", (d["choices"][0]["message"].get("content") or "")[:60])
elif "content" in d:
    t=[c.get("text") for c in d["content"] if c.get("type")=="text"]
    print("id", d.get("id"), "| model", d.get("model"), "| text", (t[0] or "")[:60] if t else [c.get("type") for c in d["content"]])
else:
    print(json.dumps(d)[:300])
'
  rm -f "$hdr"
}
body() {
  local route="$1" model="$2" text="$3" meta="$4"
  python3 - "$route" "$model" "$text" "$meta" <<'PY'
import json,sys
route,model,text,meta=sys.argv[1:]
b={"model":model}
if route=="/v1/responses": b["input"]=text
elif route=="/v1/chat/completions": b["messages"]=[{"role":"user","content":text}]
else: b.update(max_tokens=256, messages=[{"role":"user","content":text}])
if meta: b["metadata"]=json.loads(meta)
print(json.dumps(b))
PY
}
case_run() {
  local name="$1" route="$2" caller="$3" target="$4" meta="$5"
  local text="Our refund policy, in one sentence? ref $NONCE-$name"
  echo "=== $name: $route, caller $caller plants $meta, target $target ==="
  local cb; cb=$(body "$route" "$caller" "$text" "$meta")
  local tb; tb=$(body "$route" "$target" "$text" "")
  echo "\$ curl -sS $A$route -d '$cb'"
  ask "$SALES_KEY" "$A" "$route" "$cb"
  sleep 2
  echo "\$ curl -sS $B$route -d '$tb'   # the other group's key, through the peer proxy"
  ask "$SUPPORT_KEY" "$B" "$route" "$tb"
  sleep 2
  echo "\$ curl -sS $A$route -d '$tb'   # same request again"
  ask "$SUPPORT_KEY" "$A" "$route" "$tb"
  echo
}
case_share() {
  local name="$1" route="$2" first="$3" second="$4"
  local text="Our refund policy, in one sentence? ref $NONCE-$name"
  echo "=== $name: $route, $first and $second share one router caching group ==="
  local fb; fb=$(body "$route" "$first" "$text" "")
  local sb; sb=$(body "$route" "$second" "$text" "")
  echo "\$ curl -sS $A$route -d '$fb'"
  ask "$TEAM_KEY" "$A" "$route" "$fb"
  sleep 2
  echo "\$ curl -sS $B$route -d '$sb'   # through the peer proxy"
  ask "$TEAM_KEY" "$B" "$route" "$sb"
  echo
}
echo "=== scope: the sales-bot key asks support-bot directly ==="
ask "$SALES_KEY" "$A" /v1/responses "$(body /v1/responses support-bot "Hi" "")"
echo
case_run responses-model_group /v1/responses sales-bot support-bot '{"model_group": "support-bot"}'
case_run responses-caching_groups /v1/responses sales-bot sales-bot-premium '{"caching_groups": ["sales-bot-premium"]}'
case_run messages-model_group /v1/messages sales-claude support-claude '{"model_group": "support-claude"}'
case_run messages-caching_groups /v1/messages sales-claude sales-claude-premium '{"caching_groups": ["sales-claude-premium"]}'
case_run chat-model_group /v1/chat/completions sales-bot support-bot '{"model_group": "support-bot"}'
case_run chat-caching_groups /v1/chat/completions sales-bot sales-bot-premium '{"caching_groups": ["sales-bot-premium"]}'
case_share responses-shared_group /v1/responses team-a team-b
case_share messages-shared_group /v1/messages team-a-claude team-b-claude
case_share chat-shared_group /v1/chat/completions team-a team-b

/v1/responses, sales-bot plants model_group: support-bot

Before, support-bot gets the planted answer

$ curl -sS http://127.0.0.1:27582/v1/responses -d '{"model": "sales-bot", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-model_group", "metadata": {"model_group": "support-bot"}}'
HTTP/1.1 200 OK | 1289ms | x-litellm-cache-key: (none)
id resp_8CiYHo7G-0t_Yt568KiAUHRHSZ3j9tg5BILoDOgMzi0lJqqzaSpqzGzOvh7b7QSlx-IYPITGm-Ry8xwOEMNa5o56M181g7sIndJ3oPHH0MRHtu1dJb-HTiprwaMsVxm4Sc1IjqT39mEKj04l6aUy34KhCmfJ9WnPGG4N3eQiBDdK1xIyvfc2gqS1aDunlxSEdEAyV0ysQqyBH8osW8Kfcpt8SeUGJuOvxSI2JQJ5sHGlQsvUS2ZK1EggzvwjzBQg5XmihboGmLfDrKX5q-ljbgU6Jv5eXyijYdThhGpzlQHlTSLSwXOpmq5oIOseNcErSUD7N8QU6o1HolyFfjoHri0jPeLq97zWf783e8WEKRKWKb6vXtSS4JES7EY07FvAwnP65KbXCPvebQzSeMEBFnr_Yg_oCkmUttPS5zYmuMxK3YWpAr4GOwFELhhZkGWaEWSS | model sales-bot | text Refunds are available within the policy period for eligible 
$ curl -sS http://127.0.0.1:26503/v1/responses -d '{"model": "support-bot", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-model_group"}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 53ms | x-litellm-cache-key: 9670545a351dee1e0ba
id resp_QAgQOmcIw3IJ3Mo4cG5UImK1inPaP97bxPLx9EI-DZjNlJZVAaQn2ho8XfbQxxnST2T3p92O_bAGomxjnCRG8pXFYmmMB0qmUlBoS_10Zw_uqYhxYnfLPSifKFFYiWqm1ENJ833pzdyL1PpGgebudxwD9GFYwFUgszW8fSc5iNpViGkznoVh4RH_RoZI1WhBQwFnca88DsQds-IftUGMMMyoSnJJSKgE6dIkvs8dk-RY0ziPU76cvjNFPm0Id4JAQPCk6izQyqgCXJjyzoULEHHfa4uT8hTs0vHJSEhDl5BeOkorusTsthWUmF5UF76ikZFa-U-HEobptKVwyU_pAryaMHmk6j7ySKzTYewREKgC5qNqHZzdGHguVZgXRaoFI6SJJfCLJI1LaQsgzexcPfIFQAuljjYhSCwjmIKBnYSdZdmNXgl4-qRLSl1MT8iCpCJ- | model support-bot | text Refunds are available within the policy period for eligible 
$ curl -sS http://127.0.0.1:27582/v1/responses -d '{"model": "support-bot", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-model_group"}'   # same request again
HTTP/1.1 200 OK | 53ms | x-litellm-cache-key: 9670545a351dee1e0ba
id resp_QMyyLR3GIdKXyJ0P43i9dd0221k7A9gjM95XgtUtMVz1YtTi-E2ejwEv3vhSwj9xz6so-Ww1VAt0PoSFL5jDPV8KDRFyv58hgsCMuZLmhIQGnbEC1z-w9QFDQDQ-y0rCo2Q4Z7pzvNzVFz_PiyplLr9h8ZcnQh77rhO15W775MGRAwXLDJva1CO9vYalaOcuGhQWmB3Mxo7ZD3MmdJ7rmqGdnh_N55xyrg_QPsg8Eal60OzkTCFpS2mJY8rRyQrW28y2N3DT8Ksnkx7sKeQPhC0Y81-Fm3Fgr_ovNq0CTf1xKKlFy5-8EOI691bb_aueXA1eIh20JKY07rNdnZHvRLLP6JwExRlo-cmlvAzTtj0X1kopVNtBqZwsV4J8LlofHCJTrcP28iZ-3HRIji3YAuuQQlBYkAW9VAru3bVoPelRRpjNFI7Ue2okJpQfNeYrZt6l | model support-bot | text Refunds are available within the policy period for eligible 

After, its first ask misses the cache

$ curl -sS http://127.0.0.1:25618/v1/responses -d '{"model": "sales-bot", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-model_group", "metadata": {"model_group": "support-bot"}}'
HTTP/1.1 200 OK | 1798ms | x-litellm-cache-key: (none)
id resp_f6IVAbR4uXn9Pip5Qfl-4jxIEA4hmB7ueix_leyDbdHJNfk3h88bgUE2mxLPa2OTz9a79E9HaLryoOe136qHvpLCj9bugUwLut35_Cg5ulmLywgW7ujZezBjDLGlBTkHk3QtE38YPBMT4a-3g2UXnQMEd7WkYyNYxJGCch1MQ0MxNCBQ8TgKZe44HXIuvaRCtmh7qWH_zLdSMXaIxcZRBAUYFoYUFOQWwp07hJH2T9j6xTNCY2QN1RsWkPxiefQbykXh3skSFRweNDe8ZCuwgvC4IVE6Lr-mnIwMv8QAlqMlUyUBLTVnjyHd13IRnwznAgWCe5K7SfDd3qkjvZMG-aU5LCoDS1ywEfZ0o-2p0St9w-0XGPWfup9j_-6NEVJzOWuMsBI215uLDmEO4vWDFcEdCTw-xuCRiHuKMSKwK4ODHMoCtQDe-D4rbhn_dXRIhh2r | model sales-bot | text I can help, but I don’t have your refund policy text from th
$ curl -sS http://127.0.0.1:24583/v1/responses -d '{"model": "support-bot", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-model_group"}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 6925ms | x-litellm-cache-key: (none)
id resp_rw1dCxczgCLCV6kK7cPeeOXkt0-QJp4RcyrfzZKH-pU7lpiDVANEj3wyLa5TyFLRNh0WQS5wab2CV-XNO3-XMBp5hV7GCGNfFJOyghLPQGBeq5lzDWs7zvoRu2BHdWiDPohUq6Xs5_OiEXsFyrwGe-vvredbYYg1eHesxJFhpD1TmVkNBDj4AXCNmwMlljUjHV90L6EWc95KGEdZ4Sc_ePVr0plC8PB41-KDiTWVhHw7rSajk21AqscC25-TIPyIZHcPu8012UDag5NrJMqg7UiEzSVMhWI4QoSJpcdeK5_Q-I0NiNaZdFcZKoQ4toc7EQNn2MgTMxZwcAW2_6BWmUQu7D-fWmmqvX03n8vzHoNAc8zGGpTLxLT-GxiCrWSY0aEpso6FzU8O8AOifyPEcKmvEkvxI563pH880uOW3a9K4WSrwZrwdy2aQ-mGm0RaYONx | model support-bot | text I don’t have access to your refund policy; please share it o
$ curl -sS http://127.0.0.1:25618/v1/responses -d '{"model": "support-bot", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-model_group"}'   # same request again
HTTP/1.1 200 OK | 50ms | x-litellm-cache-key: 4d52b129c4dec23ccf6
id resp_VTkJvyft1p3Q4HOFQ6LpFIRskjDwV3yJVC8htvt8JnAeth2c9MxO0hX5U2Kl4ZQBC8Uhxj0skpEPZeAdTFowJJc6v3dfWxGn9lkgLQNmt3ONpCbwmrBwr2Uti8eMdmS42l2eIfSEsH4hmk535pOpsSo9BKOixvbyIUPgMMzzB_PRndohjf8ehp-txVuYp88GitM-lnXdDPzzSQE5QyENmr5cYtXGsnExA19tmIHEsmI39PSN5qYsqmIP7e5RfRG6p92e2aDnkzuNVxNK2qHT7-YYPwAKtF84nIkNes0as83iYRNp8d-VCwXcj3Zu98bEm0RG_1eruAA8tXmOxhHPv2I6arOauHtNkLVw1m_a7humBIP1xmq2z9QwBpcwnxPUakqwsPsuHm8WlL__2kXTawfO7HgxDNif14gnws0xvIplKHqlHixiFT6sYCTWWqUndC4a | model support-bot | text I don’t have access to your refund policy; please share it o
Scope check, the `sales-bot` key asks `support-bot` directly

Before (a604c89)

HTTP/1.1 403 Forbidden | 49ms | x-litellm-cache-key: (none)
{"error": {"message": "The requested model 'support-bot' is not available for this API key, or the model name is invalid. Check the models available to you and try again.", "type": "key_model_access_denied", "param": "model", "code": "403"}}

After (3550057)

HTTP/1.1 403 Forbidden | 83ms | x-litellm-cache-key: (none)
{"error": {"message": "The requested model 'support-bot' is not available for this API key, or the model name is invalid. Check the models available to you and try again.", "type": "key_model_access_denied", "param": "model", "code": "403"}}
`/v1/responses`, `sales-bot` plants `caching_groups: [sales-bot-premium]`

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/responses -d '{"model": "sales-bot", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-caching_groups", "metadata": {"caching_groups": ["sales-bot-premium"]}}'
HTTP/1.1 200 OK | 1237ms | x-litellm-cache-key: (none)
id resp_4cB5uj4FhbbDZrNU_TB2NH9Fj8xHbsUmbZn1qPt7Ysvmtkqj0tloznnKsA0OpKeHplC1FL8nYcADSjtyib2y58_JwjGE-8FC9DKGKZvvpF2SJf1tXSL4YXnvp9CK2gH5q0_5wL_G9_HMpN5w8heqZiDPmVcAKtC7nrSt9-_zjotdbHdrShHWnGnSE3QyAqrq-th4IVgoS84Uh43A6e17eGyFVIQtGzXR523pVbwVElzGcePV-7Y2yBQc45EyH_vlK4QqptgJOE0ofXQeebocwzLdSlb87Ia4uuQ_OIGfBeafsEnPyFslGzGUCs1rDD5LyAf6wK891aaOhJfBDR_YLlBkpxnU0QaA9R-or3_tHVtpyYqXYiysI2FX_npmbbxTJeejJruItGzPgtgZwYoPsbtw_rbC5aF3nvvylctGziMKjJHNHETo9jl5py1XaYlMm35Q | model sales-bot | text I don’t have the refund policy text or the referenced record
$ curl -sS http://127.0.0.1:26503/v1/responses -d '{"model": "sales-bot-premium", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-caching_groups"}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 66ms | x-litellm-cache-key: d8ea57c8fbd07ebe9d4
id resp_61HxKVsDAiS2PG3FQSSTar1LtfMRenD532UkNlyqoTbixdVUWApPCOlqIu3-AWkbOGjLM-g8b5yZww3vW1dtxCSGJAVKmdU1VMqyiZfUDWFTIALtjQj5pg1pK8HLHgMdsq7AeufPg4n1f2uG56_6r4xXDIBCyB3WSewDR4109ryxzzuQJbFFA_bpGikvmxBBxl8Fg-swXrcjxYd9bSTnDMRUvUGoW1_TvoXaw-PomkcnRO2DW9jd6Em-qORnVsUg6toHpeEJnDuUBU-yNv9ycF1r01PcNzq5fHh0BN5LWHVTnyKpG7Tqg4VfqPsHiqtm2skybiLEuxS_maxAU-yUf7_PjNBHcNPnyJO9BbjsyCnykjCcNg-Ecb15yuhflbWigi0ZmLkzYqZPRwoRhRHGa_iKdoC6dOGM6AIh50xWIlVjaEvE5Riq9pv-w5SMhQk91xju | model sales-bot-premium | text I don’t have the refund policy text or the referenced record
$ curl -sS http://127.0.0.1:27582/v1/responses -d '{"model": "sales-bot-premium", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-caching_groups"}'   # same request again
HTTP/1.1 200 OK | 35ms | x-litellm-cache-key: d8ea57c8fbd07ebe9d4
id resp_LR-Ms0dGZcRVAS2PmcowNLEav7T3ECdL4ZEjoFNy0uMgNJqP0IDixGikKHXpTOdAInw_G8S6K4zSpyDtGczxtf7xMxJcmcEtOFz2HI4A-ILJ_9YUJKkUfHhHOWQTyd0CFP89mffDzQpfCWCvAKH7kmzvLv4LqRpFmSGIs9FaoNaocdtq23m97JF172aN3QYGhaKYBPRr3YJ4tIZmueanCkniLGdBYyICMXEXtwFgA9VAnUg1gFJu2W8ANMs8Af5VQLeiE9JpoE54C86dFYe7r36XSfjNRdeqk1F5FfGiAfLxmSbSeLVDz1NTCwAqfTo7FbDFW6d5hyHpN-Gwf_qtTku5sngj0itLe2rxhG6m4_xgtmAYDAWscOKh0PMiroxZqj0AcI0_qepxqKGsATTFl69s79ts0ke-HTOP1ht3TQrCncnn-SOoym5pDk1QJ1soIAbE | model sales-bot-premium | text I don’t have the refund policy text or the referenced record

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/responses -d '{"model": "sales-bot", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-caching_groups", "metadata": {"caching_groups": ["sales-bot-premium"]}}'
HTTP/1.1 200 OK | 1531ms | x-litellm-cache-key: (none)
id resp_CiBNOnIAGIk3t_KETiyyYApkKSG-0ec1p_gVrjU9Ii__BqqNHOcvJjozispO96cq-7yWjbfUf8D3qJrnx0S0CUeiPIZ0iPW3Dz3H88vNVfYm0UcqtLzuWipTAGc52OR40n5Aw4R4JW7umXm5exRNkMp6ZtgRy4kyr4yRDeU5IkQyBGMBan1sKfwXoQoNTW1zG4s2EuHGp4O6lrdG5kKZwnx-YwidHtl5rshZ4ymkVBrVUnDpFqZyBWD4pflfvkFCIQkZB7DDOUc1zvKJ16vATBUX-B9gDFNB9S0B-GFbWqZfcst-rCtSlaPa2w-PkRELNUfSiIj_r8BAqHg6GDHj9qkgVa6yzRx4KO-mHAlck3TaVywl8SR5rhdKgqv-kBbuUtILeNn2ocwWYimFD2lFxeQcRLKz-xbpJO6THPJk4k8p8KUncgyEOUZngbgkLbYgeBxG | model sales-bot | text I don’t have the actual refund policy text for reference **1
$ curl -sS http://127.0.0.1:24583/v1/responses -d '{"model": "sales-bot-premium", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-caching_groups"}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 5339ms | x-litellm-cache-key: (none)
id resp_yrgdPTjDDDt0_SJWkdXeZRavUCMwUeY4GGyWUfQKz18u2mDeJrNNNSxGtdIee2u2yO5wraeaY2gfzT01dj5IaEijaWmTje2huQ6OhXXFqgTDhZYiA4iW78pETUNmsTywRF7i5yI6xJL17lxZ11lk834uDXMP859aFjuWMePOdDoK1X3Ye9TX3EtvQEQiCcbwfwdtdGMNR41aD3PfO-8b4slDU1qKG6H2uGNJvjuj51Xp8-xedrXxhg_6h1K1DWl_gH6gaOL5CkCwmMpTvC8aLWaj6aBlcya0C4Ec0tgiUvjs9Gl8kmwXspB7ZxthYcmr8_tQ8qa8t4w_Qfmfhn5y5D06B9nTGap9rC-ez1LgplHgEYirIMyqXyQ-nkDjJkMC9CwGuQY8fBDT4HETy-yaWvrO6wSGp0SWoZism1Vw5JurFzwoilE5mWKxgFunTWeLtxiM | model sales-bot-premium | text I don’t have access to the refund policy for reference 17932
$ curl -sS http://127.0.0.1:25618/v1/responses -d '{"model": "sales-bot-premium", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-caching_groups"}'   # same request again
HTTP/1.1 200 OK | 29ms | x-litellm-cache-key: 3c54267f51f2839184b
id resp_FpGqOHxrNohiSQaU63Mqsy-9MlJZpcyoVZydEm3c0u85VEnzLXZE1H37fPjTSp1tqYFnjmPdudyEPypy-33WvFkWuhbOBV4uFusGivEHk0nx9C0OIEcrAg1gkryjjS4UNfife4oENWVr4yUc8gt2H_42BAQibne5TlWoiSluZbHcQmoLEJLKh6HgIFTD8zkGc5fVxP7KrtGimZlxLtE20463m9ZfF5V5aYcphZXYfCtFc7jWVB32NYsbIorUjbZtxxI12tF6M27pIUqXyEoHZ0G3SeLjnlMYOn2gePeHCJX980uEgsFis2_a-jG9oum03Brxe22zXTqH_2fbMeGdeJfHDg2ZC077Zt-MkOuEk8fyqznHKSMFF34w9amWLePstQQQGI-MRaIbE40UcrzGY6pfOhUvhCcos8YstPxinbjv8l15wh0gJLuJLTXjtYjFTzqS | model sales-bot-premium | text I don’t have access to the refund policy for reference 17932
`/v1/messages`, `sales-claude` plants `model_group: support-claude`

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/messages -d '{"model": "sales-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-model_group"}], "metadata": {"model_group": "support-claude"}}'
HTTP/1.1 200 OK | 1439ms | x-litellm-cache-key: (none)
id msg_011CgVfLtxYEwa3KbaAWspmS | model sales-claude | text I don't have access to your company's refund policy or any s
$ curl -sS http://127.0.0.1:26503/v1/messages -d '{"model": "support-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-model_group"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 29ms | x-litellm-cache-key: 0258cc698b6c23231ef
id msg_011CgVfLtxYEwa3KbaAWspmS | model support-claude | text I don't have access to your company's refund policy or any s
$ curl -sS http://127.0.0.1:27582/v1/messages -d '{"model": "support-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-model_group"}]}'   # same request again
HTTP/1.1 200 OK | 44ms | x-litellm-cache-key: 0258cc698b6c23231ef
id msg_011CgVfLtxYEwa3KbaAWspmS | model support-claude | text I don't have access to your company's refund policy or any s

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/messages -d '{"model": "sales-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-model_group"}], "metadata": {"model_group": "support-claude"}}'
HTTP/1.1 200 OK | 1936ms | x-litellm-cache-key: (none)
id msg_011CgWDKrNUJRmwwUaCMVVQj | model sales-claude | text I don't have your refund policy. The reference you included 
$ curl -sS http://127.0.0.1:24583/v1/messages -d '{"model": "support-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-model_group"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 2929ms | x-litellm-cache-key: (none)
id msg_011CgWDL8rukbR44Ce5d7XeS | model support-claude | text I don't have your refund policy, and the reference string (1
$ curl -sS http://127.0.0.1:25618/v1/messages -d '{"model": "support-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-model_group"}]}'   # same request again
HTTP/1.1 200 OK | 70ms | x-litellm-cache-key: d66c175c5556d20d84a
id msg_011CgWDL8rukbR44Ce5d7XeS | model support-claude | text I don't have your refund policy, and the reference string (1
`/v1/messages`, `sales-claude` plants `caching_groups: [sales-claude-premium]`

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/messages -d '{"model": "sales-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-caching_groups"}], "metadata": {"caching_groups": ["sales-claude-premium"]}}'
HTTP/1.1 200 OK | 1533ms | x-litellm-cache-key: (none)
id msg_011CgVfMKmJLpKxPkEHJoFDA | model sales-claude | text I can't look up that reference. I don't have access to your 
$ curl -sS http://127.0.0.1:26503/v1/messages -d '{"model": "sales-claude-premium", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-caching_groups"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 27ms | x-litellm-cache-key: 948ea201886733c0c3d
id msg_011CgVfMKmJLpKxPkEHJoFDA | model sales-claude-premium | text I can't look up that reference. I don't have access to your 
$ curl -sS http://127.0.0.1:27582/v1/messages -d '{"model": "sales-claude-premium", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-caching_groups"}]}'   # same request again
HTTP/1.1 200 OK | 29ms | x-litellm-cache-key: 948ea201886733c0c3d
id msg_011CgVfMKmJLpKxPkEHJoFDA | model sales-claude-premium | text I can't look up that reference. I don't have access to your 

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/messages -d '{"model": "sales-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-caching_groups"}], "metadata": {"caching_groups": ["sales-claude-premium"]}}'
HTTP/1.1 200 OK | 2040ms | x-litellm-cache-key: (none)
id msg_011CgWDLXAb21pp7yqWedKGm | model sales-claude | text I can't see your refund policy or look up that reference (17
$ curl -sS http://127.0.0.1:24583/v1/messages -d '{"model": "sales-claude-premium", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-caching_groups"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 3528ms | x-litellm-cache-key: (none)
id msg_011CgWDLpwRbD3HhPJyHnpqw | model sales-claude-premium | text I don't have access to your refund policy, and the reference
$ curl -sS http://127.0.0.1:25618/v1/messages -d '{"model": "sales-claude-premium", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-caching_groups"}]}'   # same request again
HTTP/1.1 200 OK | 36ms | x-litellm-cache-key: e10f20d49528ba0a719
id msg_011CgWDLpwRbD3HhPJyHnpqw | model sales-claude-premium | text I don't have access to your refund policy, and the reference
`/v1/chat/completions`, `sales-bot` plants `model_group: support-bot`

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/chat/completions -d '{"model": "sales-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-model_group"}], "metadata": {"model_group": "support-bot"}}'
HTTP/1.1 200 OK | 1171ms | x-litellm-cache-key: (none)
id chatcmpl-Ee9FMpWRlwqSH5AbRVdhXwHYo8BIS | model sales-bot | text I don’t have the refund policy text here—if you paste it, I 
$ curl -sS http://127.0.0.1:26503/v1/chat/completions -d '{"model": "support-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-model_group"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 1923ms | x-litellm-cache-key: (none)
id chatcmpl-Ee9FP4MQ6bfCliBFLZU2V0AQ5PR7c | model support-bot | text Please share your refund policy text so I can summarize it a
$ curl -sS http://127.0.0.1:27582/v1/chat/completions -d '{"model": "support-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-model_group"}]}'   # same request again
HTTP/1.1 200 OK | 26ms | x-litellm-cache-key: e4e53c0a690732bae88
id chatcmpl-Ee9FP4MQ6bfCliBFLZU2V0AQ5PR7c | model support-bot | text Please share your refund policy text so I can summarize it a

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/chat/completions -d '{"model": "sales-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-model_group"}], "metadata": {"model_group": "support-bot"}}'
HTTP/1.1 200 OK | 709ms | x-litellm-cache-key: (none)
id chatcmpl-EeFnLbrhS70dMvT4L0uxPcmQhUys6 | model sales-bot | text Please share your refund policy text, and I’ll condense it i
$ curl -sS http://127.0.0.1:24583/v1/chat/completions -d '{"model": "support-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-model_group"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 3114ms | x-litellm-cache-key: (none)
id chatcmpl-EeFnOefD7CsDVSvDBxOjoeiZDH6XA | model support-bot | text I don’t have access to your refund policy; please paste or l
$ curl -sS http://127.0.0.1:25618/v1/chat/completions -d '{"model": "support-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-model_group"}]}'   # same request again
HTTP/1.1 200 OK | 25ms | x-litellm-cache-key: ab3fb15dc2db8ae9faf
id chatcmpl-EeFnOefD7CsDVSvDBxOjoeiZDH6XA | model support-bot | text I don’t have access to your refund policy; please paste or l
`/v1/chat/completions`, `sales-bot` plants `caching_groups: [sales-bot-premium]`

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/chat/completions -d '{"model": "sales-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-caching_groups"}], "metadata": {"caching_groups": ["sales-bot-premium"]}}'
HTTP/1.1 200 OK | 831ms | x-litellm-cache-key: (none)
id chatcmpl-Ee9FTwKQsyPOWAFBZ0eVDLdRHqx1x | model sales-bot | text I can help, but I don’t have your actual refund policy text 
$ curl -sS http://127.0.0.1:26503/v1/chat/completions -d '{"model": "sales-bot-premium", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-caching_groups"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 2124ms | x-litellm-cache-key: (none)
id chatcmpl-Ee9FWV7eyFarVmkjqUSQKOO25BeAF | model sales-bot-premium | text I don’t have access to refund policy reference 1793237348-ba
$ curl -sS http://127.0.0.1:27582/v1/chat/completions -d '{"model": "sales-bot-premium", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-caching_groups"}]}'   # same request again
HTTP/1.1 200 OK | 27ms | x-litellm-cache-key: 8ad66d33f1e990ed088
id chatcmpl-Ee9FWV7eyFarVmkjqUSQKOO25BeAF | model sales-bot-premium | text I don’t have access to refund policy reference 1793237348-ba

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/chat/completions -d '{"model": "sales-bot", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-caching_groups"}], "metadata": {"caching_groups": ["sales-bot-premium"]}}'
HTTP/1.1 200 OK | 727ms | x-litellm-cache-key: (none)
id chatcmpl-EeFnTWBv8qFOsVSRZbVRUVG58Ms3E | model sales-bot | text I don’t have your company’s refund policy details from that 
$ curl -sS http://127.0.0.1:24583/v1/chat/completions -d '{"model": "sales-bot-premium", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-caching_groups"}]}'   # the other group's key, through the peer proxy
HTTP/1.1 200 OK | 5544ms | x-litellm-cache-key: (none)
id chatcmpl-EeFnWZ6EbHH7ZGpRW9a2QlOgo06nX | model sales-bot-premium | text I don’t have your refund policy details—please share the pol
$ curl -sS http://127.0.0.1:25618/v1/chat/completions -d '{"model": "sales-bot-premium", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-caching_groups"}]}'   # same request again
HTTP/1.1 200 OK | 32ms | x-litellm-cache-key: aec5243e1c5e1354336
id chatcmpl-EeFnWZ6EbHH7ZGpRW9a2QlOgo06nX | model sales-bot-premium | text I don’t have your refund policy details—please share the pol
`/v1/responses`, `team-a` and `team-b` in one router caching group

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/responses -d '{"model": "team-a", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-shared_group"}'
HTTP/1.1 200 OK | 2567ms | x-litellm-cache-key: (none)
id resp_Il-iJnrOzBCZu4hcxaAGgvDwBg-Jp2oSiO1M9NIqRG05hOpX6YmefYX7WuwLFSKYJBtb4W0GXyRBMQ8U-QD_GU9iBToDQzMA9Tr3l4xIJXp5MtZfFeNf8Fr3DZUkVX34ghOqnLyCEAufqgvxgDxv4-43NKvTJrTiHq6L6JLhUVKET1ZFcx6YP8BCMyunAG55q4wVluDroRorVKhBAutQ9qZ_goVw2F8uFWIgiJiJO5PHZZ8bEiQk8724-D7Ks7P6MxF-a8iY_zgh41phjUsuPuKgeRIQdnPBbP0Nzpbsfr_hBSTdqyg81-p48L1HPZmc-ej5JfIrQ73AWnIa6aYYSbGsIAH0YdK17pEwXwGllAMwSZ6FBPilYfy3lo4I1iz5NT9MkFaSN0PMDg2FH3JVydLP4sd0Oq5aMrOmAlEwsBM2ZVi9F7qrwmPQ1KJ1HLZvKx0- | model team-a | text Please provide the refund policy text or relevant details, a
$ curl -sS http://127.0.0.1:26503/v1/responses -d '{"model": "team-b", "input": "Our refund policy, in one sentence? ref 1793237348-base-responses-shared_group"}'   # through the peer proxy
HTTP/1.1 200 OK | 52ms | x-litellm-cache-key: df3e3ae10d5b43e4847
id resp_LWO0Rp7goQKUykK3D6zlfHH8pzKUvijcCMsEEOCdDYnkcrgELhodGfeVF6DMJOadQGx6sGuCudhlLpDN7QfmgE56hOKQ9t4Mq0nThnQiLXDD7e4ffEtRW2MIQkNfKkqWWuoAWi7-iUPEZHdllaiq5Gi0RyfnR03No9MiYdqo_LSiO0sV3Qg-8o_XY1_kZLWozeDmvknuBgJxE6Fqaz6T9Hhtd2SSV5Y9qmYm7lPqrdseRF1WpSb1CfU5ZO4oDEIn_4PJBD7plhav65g3G3sulZtR5_bun_sIkwSmE_IanSdwiyjDUDlW6_-4fUpjPtz_z_UbctAVPRi81lDkIz2g1r16bI4ZOY7MpzSc2b6JIVO_hugMddes-YsRTEKVBrHjsaEq-0z8sl_2dWYZIYHnTjS_dmarGNBgvuPCkzmWpCEiFEcOVXsQxAXgmMDgOeFHVy-2 | model team-b | text Please provide the refund policy text or relevant details, a

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/responses -d '{"model": "team-a", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-shared_group"}'
HTTP/1.1 200 OK | 5360ms | x-litellm-cache-key: (none)
id resp_TVJQvSmd-efiL9vOlCjkGLi59Mxij4kumz35wQUyeX0TcJoEDLi8YdocOq2isqcnVUreUpv4SvMWsjQcjr1-D0FzNIFw7bYh8qfZFvKWOzFrBMDP5he9ygoiEeWSRrdhCxIOjXUGG28SufDZg0pOq6KnHAJYlJqyxZo_PikIFDSThlSkJOwtLQCfoPCg_Uc-LpD7Lxm2KxeHbT3ZeNdyKRG91bocAY01hjvwQUvqKPaKZVhe9A2qP6tLkNKJZMNYRqV9w0OOZ-g_Cy0yTfunJyQ_kVVH8FzCYxHLb8s9KBssPoUd-X0oJLpuE0M8sEVnaxOCgAFv7NXSxD92EegGvMcgeZgWG1xjhnSbW3uqDhjW4rkvs4BGQ1UYwvZLgEwRCxykPbjvpCEwNXY8TWVex4Kfn0cYOGRkwcSNPibDYILVVUOlaP8qCmZdukgSXXC8CNS1 | model team-a | text Please share the refund policy text or source linked to ref 
$ curl -sS http://127.0.0.1:24583/v1/responses -d '{"model": "team-b", "input": "Our refund policy, in one sentence? ref 1793262499-head-responses-shared_group"}'   # through the peer proxy
HTTP/1.1 200 OK | 52ms | x-litellm-cache-key: d6f354dc9c97557c0a1
id resp_JbyVI677lXKYD5vOnqXyLRI6-8NyrOPMzB-iu70p5j_CjxpQ3SfYVeLnMeMw5Vu0MEJbQ9dR98svaB1p0CjHgZWJJHvEZO1peq0PivJlEc4kro9Qo2te31cFPD0Boz6o8jFq-iac7FRNVvr_L32yyEWnoVAYOOOzxSDhBYiexlWzKx1RjMB-yblCpWSHHTSb4Vm6XF6cpBtH4Yuf9QbIc3fJAXDxXMJ4e8z8V0tQCm_kmq8lW6c-55angBQRO1xdGCYdNNcoj-fQCzVGGvT6hzJBoPmrjIkb2KfJrsvvzjh0jwxN5fEv3YN6q2c2agARBP61gdWfCrmGtrFiwWpGb_pUGj2vlwxtzCdQGfQC1gmALDk3CgvzSm6glTip7ch1FUKCSxq3xQ9301f5D467_IqPdKAHsFL6oJccymttcyt50-UE1sghpvYsVefqAQWtpx6j | model team-b | text Please share the refund policy text or source linked to ref 
`/v1/messages`, `team-a-claude` and `team-b-claude` in one router caching group

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/messages -d '{"model": "team-a-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-shared_group"}]}'
HTTP/1.1 200 OK | 2594ms | x-litellm-cache-key: (none)
id msg_011CgVfPBRYeNgSoYQMUGUQ5 | model team-a-claude | text I don't have your refund policy. Nothing in this conversatio
$ curl -sS http://127.0.0.1:26503/v1/messages -d '{"model": "team-b-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-messages-shared_group"}]}'   # through the peer proxy
HTTP/1.1 200 OK | 33ms | x-litellm-cache-key: 06dc42318b24639be17
id msg_011CgVfPBRYeNgSoYQMUGUQ5 | model team-b-claude | text I don't have your refund policy. Nothing in this conversatio

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/messages -d '{"model": "team-a-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-shared_group"}]}'
HTTP/1.1 200 OK | 2891ms | x-litellm-cache-key: (none)
id msg_011CgWDPBx2sKmFPGxYMitQw | model team-a-claude | text I don't have access to your refund policy, and the reference
$ curl -sS http://127.0.0.1:24583/v1/messages -d '{"model": "team-b-claude", "max_tokens": 256, "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-messages-shared_group"}]}'   # through the peer proxy
HTTP/1.1 200 OK | 29ms | x-litellm-cache-key: a7b3b01d7b5cef6e61a
id msg_011CgWDPBx2sKmFPGxYMitQw | model team-b-claude | text I don't have access to your refund policy, and the reference
`/v1/chat/completions`, `team-a` and `team-b` in one router caching group

Before (a604c89)

$ curl -sS http://127.0.0.1:27582/v1/chat/completions -d '{"model": "team-a", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-shared_group"}]}'
HTTP/1.1 200 OK | 2515ms | x-litellm-cache-key: (none)
id chatcmpl-Ee9FkB3c9f3ISlJOPhgOawcXSyMln | model team-a | text I can summarize it in one sentence if you paste the refund p
$ curl -sS http://127.0.0.1:26503/v1/chat/completions -d '{"model": "team-b", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793237348-base-chat-shared_group"}]}'   # through the peer proxy
HTTP/1.1 200 OK | 67ms | x-litellm-cache-key: 159701dac99a0de2bf3
id chatcmpl-Ee9FkB3c9f3ISlJOPhgOawcXSyMln | model team-b | text I can summarize it in one sentence if you paste the refund p

After (3550057)

$ curl -sS http://127.0.0.1:25618/v1/chat/completions -d '{"model": "team-a", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-shared_group"}]}'
HTTP/1.1 200 OK | 8296ms | x-litellm-cache-key: (none)
id chatcmpl-EeFnrOVIXevDIBn9OOEhsKaVOKsgi | model team-a | text I can summarize it in one sentence, but I don’t have access 
$ curl -sS http://127.0.0.1:24583/v1/chat/completions -d '{"model": "team-b", "messages": [{"role": "user", "content": "Our refund policy, in one sentence? ref 1793262499-head-chat-shared_group"}]}'   # through the peer proxy
HTTP/1.1 200 OK | 28ms | x-litellm-cache-key: a4ea60fa5f6ac2476b8
id chatcmpl-EeFnrOVIXevDIBn9OOEhsKaVOKsgi | model team-b | text I can summarize it in one sentence, but I don’t have access 
SDK, `Router.acompletion` and `Router.aembedding` forward a parent's `litellm_metadata`

Two chat groups and two embedding groups on different models, each call carrying the same parent litellm_metadata with the parent's model_info, as the auto router's classifier embedding does. Each group must get its own answer and its own vector size, and a repeat of the first group must come from the cache. Run with python sdk_forwarded.py <checkout> and OPENAI_API_KEY set

import asyncio
import sys
import time

sys.path.insert(0, sys.argv[1])
import litellm
from litellm import Router
from litellm.caching.caching import Cache

litellm.cache = Cache(type="local")
router = Router(
    cache_responses=True,
    model_list=[
        {"model_name": "nano-bot", "litellm_params": {"model": "openai/gpt-5.4-nano"}},
        {"model_name": "mini-bot", "litellm_params": {"model": "openai/gpt-5.4-mini"}},
        {"model_name": "embed-small", "litellm_params": {"model": "openai/text-embedding-3-small"}},
        {"model_name": "embed-large", "litellm_params": {"model": "openai/text-embedding-3-large"}},
    ],
)
parent_metadata = {"model_group": "auto-router-group", "caching_groups": None, "model_info": {"id": "auto-router-deployment"}}
ref = time.time()


async def chat(group):
    r = await router.acompletion(
        model=group,
        messages=[{"role": "user", "content": f"Name the model you are in five words. ref {ref}"}],
        litellm_metadata=dict(parent_metadata),
    )
    print(f"chat {group}: id={r.id} model={r.model} cache_hit={r._hidden_params.get('cache_hit')}")


async def embed(group):
    r = await router.aembedding(model=group, input=[f"route this prompt {ref}"], litellm_metadata=dict(parent_metadata))
    print(f"embedding {group}: dims={len(r.data[0]['embedding'])} model={r.model} cache_hit={r._hidden_params.get('cache_hit')}")


async def main():
    await chat("nano-bot")
    await asyncio.sleep(1)
    await chat("mini-bot")
    await asyncio.sleep(1)
    await chat("nano-bot")
    await embed("embed-small")
    await asyncio.sleep(1)
    await embed("embed-large")
    await asyncio.sleep(1)
    await embed("embed-small")


asyncio.run(main())

Before (a604c89)

chat nano-bot: id=chatcmpl-EeBGcHqqF7tBgK8a1HX2qoPpvCzdC model=gpt-5.4-nano-2026-03-17 cache_hit=None
chat mini-bot: id=chatcmpl-EeBGg9jXdX9XpDHpIJ9wb1hHkrcQY model=gpt-5.4-mini-2026-03-17 cache_hit=None
chat nano-bot: id=chatcmpl-EeBGcHqqF7tBgK8a1HX2qoPpvCzdC model=gpt-5.4-nano-2026-03-17 cache_hit=True
embedding embed-small: dims=1536 model=text-embedding-3-small cache_hit=None
embedding embed-large: dims=3072 model=text-embedding-3-large cache_hit=None
embedding embed-small: dims=1536 model=text-embedding-3-small cache_hit=True

After (3550057)

chat nano-bot: id=chatcmpl-EeFmqc5BZhbCzMCyoHnmobbKZ9uTU model=gpt-5.4-nano-2026-03-17 cache_hit=None
chat mini-bot: id=chatcmpl-EeFmtbTr0UfPvo7gs6mvp852yXYVi model=gpt-5.4-mini-2026-03-17 cache_hit=None
chat nano-bot: id=chatcmpl-EeFmqc5BZhbCzMCyoHnmobbKZ9uTU model=gpt-5.4-nano-2026-03-17 cache_hit=True
embedding embed-small: dims=1536 model=text-embedding-3-small cache_hit=None
embedding embed-large: dims=3072 model=text-embedding-3-large cache_hit=None
embedding embed-small: dims=1536 model=text-embedding-3-small cache_hit=True

Integration audit

Integration matrix and runs

Each leg is its own rig with a two-worker proxy, Postgres, Redis and a scripted upstream, running the accounting group's environment. The integration harness is newer than #44542, so the base is today's main with only #44542's caching.py change reverted, bb07bcd562, carrying this PR's tests. The planted model_group cells' own before state is f7b57750bb, main plus these tests without the fix

Contract Endpoint Before After x2
Two groups on one model reach their own deployment responses, messages FAIL at bb07bcd562 PASS
Same chat PASS at bb07bcd562 PASS
A planted metadata.model_group fills no other group's entry responses, messages FAIL at f7b57750bb PASS
Same chat PASS at f7b57750bb PASS
A planted metadata.caching_groups fills no other group's entry responses, messages 500 at bb07bcd562 PASS
Same chat PASS at bb07bcd562 PASS
One router caching group shares one entry across models responses, messages FAIL at bb07bcd562 PASS
Same chat PASS at bb07bcd562 PASS
Existing response cache cells all three, embeddings not run PASS
Cache key picks the router's group and its caching groups (unit) none FAIL before the fix PASS

Before

  1. uv run --no-sync python tests/integration/run.py accounting tests/integration/caching/test_response_cache_model_group_key.py at bb07bcd562
  2. 12 collected, 6 passed, 6 failed
FAILED test_identical_requests_to_two_groups_on_one_model_each_reach_their_own_deployment[responses]
  AssertionError: integration-47612dd12f814717a5abb4ca0ec5a4d0 was served the answer cached for integration-3d3f447e24e94ca299d24055778afba7
FAILED test_identical_requests_to_two_groups_on_one_model_each_reach_their_own_deployment[messages]
  AssertionError: integration-b72efef771fc42bc86d266cd5d44c815 was served the answer cached for integration-edca56f7e6844f9382fb6800a7b5c184
FAILED test_groups_in_one_caching_group_on_different_models_share_one_entry[responses]
  AssertionError: assert 'msg_cache-c4ae2d2edfe7-1211d2ec' == 'msg_cache-6953a6add804-36cb1f81'
FAILED test_groups_in_one_caching_group_on_different_models_share_one_entry[messages]
  AssertionError: assert 'msg-cache-ca2100b9a4e1-784797e7' == 'msg-cache-39e2c0673a21-bc030323'
FAILED test_a_caller_naming_another_group_in_metadata_never_fills_that_groups_entry[responses-caching_groups]
  openai.InternalServerError: Error code: 500 - {'error': {'message': "'in <string>' requires string as left operand, not NoneType", 'type': 'internal_server_error', 'param': None, 'code': '500'}}
FAILED test_a_caller_naming_another_group_in_metadata_never_fills_that_groups_entry[messages-caching_groups]
  anthropic.InternalServerError: Error code: 500 - {'type': 'error', 'error': {'type': 'api_error', 'message': "'in <string>' requires string as left operand, not NoneType"}}
  1. The planted model_group cells at f7b57750bb gave 3 collected, 1 passed, 2 failed
FAILED test_a_caller_naming_another_group_in_metadata_never_fills_that_groups_entry[responses]
  integration-269efed563dc43a5b61d252fbbf1f921 was served the answer integration-5cd4feb538804d50a065dbee907937d1 planted under its name
FAILED test_a_caller_naming_another_group_in_metadata_never_fills_that_groups_entry[messages]
  integration-57dcc2b4ed3049eab839f36d033448ac was served the answer integration-4407a220dd8244078730089c2cb68969 planted under its name

After (3550057)

  1. The same file with seed 44542 gave 12 collected, 12 passed
  2. The seven cells in tests/integration/caching/test_response_cache_empty_output.py, covering empty output, streamed replays and embeddings, gave 7 collected, 7 passed
  3. uv run pytest tests/unit/caching/test_unit_test_caching.py gave 16 passed. The router group test fails on both before commits with assert 'target' == 'caller', the caching groups test fails on 3ecc9efb7e, the forwarded litellm_metadata router test fails on 3b19b27235 with assert 'group-a answer' == 'group-b answer', and the test that keeps metadata first outside the router fails on f92ab299e8

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Low

  • Answers planted before the upgrade last until their ttl ends, so flush the cache after upgrading
  • Outside a router, a direct SDK call's own metadata.model_group still picks the cache entry, as on main. The proxy cannot reach this

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
/live-pr-risk at 3550057

Rig: base main a604c89 against head 3550057, each side two proxies with two workers sharing one Postgres and one Redis, requests alternating across them, live OpenAI and Cohere, and a recorder in front of OpenAI that logs and forwards every upstream request. The top scenarios ran again on this branch merged with main 67ae3fb and gave the same status, route, and upstream count on every row

Breaking

None observed

Backward incompatible

On a routed call, the caller's metadata.model_group or litellm_metadata.model_group no longer picks the cache entry or the caching group. A caller who used it to split the cache now shares entries inside its router group. That is the change this PR makes. One visible effect: a /v1/responses call with a 5 KB string there got OpenAI's 400 "Invalid metadata" on main, because its own key missed, and a 200 cache hit on head

Regression risk

Semantic caches (Redis semantic, Qdrant) and the S3, GCS, and disk backends were not booted. They take the key string this PR builds, so the risk is low

Dependency graph

Dependent Status
chat, stream and non-stream verified live
text completion verified live
embeddings and caching groups verified live
transcription verified live
rerank verified live
/v1/messages verified live
/v1/responses verified live
fallbacks verified live
spend rows verified live
upstream request shape and count verified live
client litellm_metadata.model_info on an opted-in key verified live, misses on both
rate limiter success event verified live, same on both
semantic and object-store caches not booted

Same on main and head, not caused by this PR: an int, list, or dict metadata.model_group on /v1/responses answers 500

Not verified

Semantic caches, and the S3, GCS, and disk cache backends

Bugbot summary

[!NOTE]
Medium Risk
Changes how cache keys are built for all router-backed LLM calls; intentional behavior change for callers who relied on metadata to split cache entries, but fixes cross-tenant/group cache bleed.

Overview
Fixes a cache poisoning issue where response cache keys could honor a caller's planted metadata.model_group or metadata.caching_groups instead of the router's values for that deployment.

_get_model_param_value now, on routed calls, picks the metadata bucket whose model_info matches the call's model_info (checking litellm_metadata before caller metadata) and uses that source for model_group and caching_groups. Non-router calls still use the existing first-match walk across metadata sources.

Adds integration tests on chat completions, responses, and messages (isolated groups, planted metadata, shared router caching groups) plus unit/router tests for forwarded litellm_metadata and caller planting. Integration Scenario.model accepts an optional fixed name for deterministic model aliases.

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

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

The cache now reads model_group and caching_groups from the metadata matching the routed call’s model_info. Calls outside the router keep the existing lookup order

Tests cover separate model groups, caller-supplied metadata, shared caching groups, and forwarded SDK metadata

mateo-berri initially accepted the earlier SDK precedence behavior as intentional because proxy chat requests use metadata. The later fix selects the routed call’s own metadata instead

Deployment note, answers planted before upgrading remain cached until their ttl expires. Flush the response cache after upgrading

  • Routed cache keys use the router's matching model group.

Reviews (7) · Last reviewed commit: "fix(caching): keep main's model group lo..." · Reviewed by Greptile

Comment thread litellm/caching/caching.py Resolved
@codspeed

codspeed Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 38 untouched benchmarks


Comparing mika-lt:litellm_audit_44542 (3550057) with main (032342d)1

Open in CodSpeed

Footnotes

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

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

A caller's own metadata.caching_groups on /v1/responses and /v1/messages could
still pick the cache key, so a string group let one model group fill another's
entry. The key now reads caching_groups only from the metadata that holds the
router's model_group.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

2 similar comments
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

… call's deployment

A router call can carry a litellm_metadata it did not write, from the auto router's classifier embedding or an SDK caller, while the router writes its own group into metadata. The cache now picks the metadata source whose model_info matches the call's deployment, then falls back to the previous order.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri changed the title test(caching): audit #44542 fix(caching): read the cache key's model group from the router's metadata for the call Oct 29, 2026
@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 3550057. 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 ebf84f8 into BerriAI:main Oct 29, 2026
90 of 93 checks passed
@mateo-berri
mateo-berri deleted the litellm_audit_44542 branch October 29, 2026 12:36
mateo-berri pushed a commit to zoveki/litellm that referenced this pull request Nov 9, 2026
…and MCP ack fix to lts/1.108.x

Backports test-only changes from main so the line's integration signal stops reporting stale helpers as failures.

Gateway.database_url and Gateway.rows come from BerriAI#47213 (fc27dfd), and the name keyword on Scenario.model comes from BerriAI#48917 (ebf84f8). Only those hunks of tests/integration/_support/client.py are taken. The rest of BerriAI#47213 gives each owned proxy its own database and Redis, which none of the line's tests need, and the workers field from a later main change is left out.

The MCP progress and cancellation test wraps its upstream in _acknowledge_notifications_after_dispatch, from BerriAI#49967 (b5952f2). The helper is already on the line.
pamanseau added a commit to KubeTEE-AI/litellm that referenced this pull request Nov 16, 2026
* fix(anthropic): stop logging rejected encrypted reasoning

The retry warning keeps provider, model, status, and error code, and leaves the ciphertext out.

Backport of the third #49076 commit to lts/1.108.x. Cherry-picked from c62c92d2ad0.

Co-authored-by: DDT <141296842+Hugo-DDT@users.noreply.github.com>

* fix(ollama): keep replayed tool arguments out of a rejected replay's error chain

Backport of #49183 to lts/1.108.x.
Cherry-picked from 0f7003a2aeb84651230b0fcbcb8403e4ed957af8 (fix-ollama-chat-stream-tool-call-index).

* fix(anthropic): start a new streamed block for each reasoning item

The backported Responses bridge tags each reasoning item's thinking block with its output index, but this line's Anthropic stream wrapper only opened a new block when the block type changed, so a second reasoning item of the same type was dropped. This ports the index check from #46863, which main already has.

* fix(anthropic): keep each streamed reasoning summary with its own item

A summary delta carries no item index, so the next item's summary joined the block that already got its signature. A thinking chunk after an indexed signature now opens a new block.

* fix(ollama): keep the repair warning's argument preview unless message logging is off

Backport of #49183 to lts/1.108.x.
Cherry-picked from 5ef6d62cca7e0a9a9e6db2609ca435e9b957de5e (fix-ollama-chat-stream-tool-call-index).
Adapted to the line. The repair warning lives in common_utils.py here.

* fix(anthropic): stream reasoning signatures only to Messages clients, keep xAI web search reasoning, and retry only when the sent request carried it

* fix(anthropic): send openai/ Messages turns again once without encrypted reasoning a backend rejects

The openai/ Responses path on /v1/messages had no retry, so a chatgpt/ block left in history answered 400 on every later openai/ turn. That path now sends the turn once more without encrypted reasoning, the same way the chat bridge does. The retry matches only invalid_encrypted_content or a "could not be verified" message naming the content, so the exception mapper's own hint no longer triggers it. The xAI web search keep path is backed out, since xAI sends no encrypted reasoning over the bridge.

Backport of 15e60170124 from #49076 to lts/1.108.x, ported by hand onto the pass_through modules.

Co-authored-by: DDT <141296842+Hugo-DDT@users.noreply.github.com>

* test(ollama): cover short and boundary-length repair warning previews

Backport of #49183 to lts/1.108.x.
Cherry-picked from 1f71ed377f459792b383bcd2bd1e5e4f4b2137ae (fix-ollama-chat-stream-tool-call-index).
Adapted to the line. The repair warning tests live in test_litellm_core_utils_prompt_templates_common_utils.py here.

* test(utils): drop a duplicate schema key the line already had on lts/1.108.x

The picks touch tests/unit/test_utils.py, so ruff now checks it, and
the line's model info schema lists supports_bedrock_native_structured_output
twice with the same value. The second copy goes

* fix(tool_choice): accept OpenAI allowed_tools on chat completions and flatten it for the Responses bridge (#49043)

Backport of #49043 to lts/1.108.x.
Cherry-picked from 28c80048ed47d53befd819f22b5ac1bb112ec3fd (main). Import conflicts in the Responses bridge and the Azure chat config resolved to the line's imports plus the helper import.

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(tool_choice): accept the Responses API's flat allowed_tools layout on chat completions

Backport of #50467 to lts/1.108.x.
Cherry-picked from e56c060363c741b24579ecc01279c992d2d339d1 (litellm_allowed_tools_flat_tool_choice).

* fix(tool_choice): drop an allowed_tools choice under drop_params and refuse conflicting flat entries

Backport of #50467 to lts/1.108.x.
Cherry-picked from 361aecae72f2a9153a12b3998c90515f679896fd (litellm_allowed_tools_flat_tool_choice). Azure chat config import conflict resolved to the line's imports.

* fix(tool-choice): keep the 400 when LiteLLM runs the tools, report auto after a drop

Backport of #50467 to lts/1.108.x.
Cherry-picked from 5f8f54a6ca0dbd5bfc443b55e4c49e34b6b8176e (litellm_allowed_tools_flat_tool_choice). Conflicts resolved by applying this commit's hunks to the line's simpler Responses bridge handler and responses() bridge branch, and appending its new tests to the line's test files.

* fix(tool-choice): refuse an excluded tool right before LiteLLM runs it

Backport of #50467 to lts/1.108.x.
Cherry-picked from e25a82c3f54ff54178b5ebb98fb1da6a753e1fe2 (litellm_allowed_tools_flat_tool_choice). Conflicts resolved by applying this commit's hunks to the line's code. Test hunks that need main-only test helpers are carried by the line's test adaptation commit.

* fix(tool-choice): drop the choice under drop_params and hand an excluded MCP call back unrun

Backport of #50467 to lts/1.108.x.
Cherry-picked from be0bb7a57e55712476b903a8244802024416bd96 (litellm_allowed_tools_flat_tool_choice). Conflicts resolved by applying this commit's hunks to the line's MCP handlers and responses(). Test hunks that need main-only test helpers are carried by the line's test adaptation commit.

* fix(tool-choice): refuse an allowed_tools entry whose name is not a string

Backport of #50467 to lts/1.108.x.
Cherry-picked from 2ac020c070c7fdd47ec912f5ae334923ec85356c (litellm_allowed_tools_flat_tool_choice). Test hunks that need main-only test helpers are carried by the line's test adaptation commit.

* fix(tool-choice): honor server-level and null-name mcp entries and stop hooks running excluded calls

Backport of #50467 to lts/1.108.x.
Cherry-picked from 939034d8a4bc3a9f7d337471ca97738df933e300 (litellm_allowed_tools_flat_tool_choice). Resolved: tool_precheck.py is not on the line, so server_labels_serving lives in litellm_proxy_mcp_handler.py. The line has no refused-turn path, so a hook turn holding a call the choice excludes answers 400 through refuse_tool_calls_the_choice_excludes. Test hunks that need main-only fixtures move to the line test commit.

* fix(tool-choice): match named mcp entries by server label and let built-in entries allow their interception call

Backport of #50467 to lts/1.108.x.
Cherry-picked from 4755727276c84a50107c3d5aef9d398e7d0d4603 (litellm_allowed_tools_flat_tool_choice). Resolved: kept only this pick's helper and import where the line lacks main's sandbox result types and core_helpers import. Test hunks that need main-only fixtures move to the line test commit.

* fix(tool-choice): leave a malformed allowed_tools choice unrewritten in the interception hooks

Backport of #50467 to lts/1.108.x.
Cherry-picked from cd076fb13ab (litellm_allowed_tools_flat_tool_choice).

* fix(tool-choice): resolve mcp entries like the gateway and keep the choice on every hook path

Backport of #50467 to lts/1.108.x.
Cherry-picked from 6be4f0b9ead (litellm_allowed_tools_flat_tool_choice). Resolved: the line has no tool_precheck.py or agentic_loop_refusal.py, so the MCP label resolver lives in litellm_proxy_mcp_handler.py and mirrors the line's own toolset resolution (admin view and granted toolsets, no access-group fallback), and the line's toolset listing now calls the same resolver. A chat hook turn holding a call the choice excludes answers 400 through the line's AgenticLoopSafetyError path. Main-only code in the conflicted hunks (internal_sub_call, first-round billing, Claude Code web search prefix) is left out. Test hunks that need main-only fixtures move to the line test commit.

* fix(allowed_tools): stop web search and code interpreter follow-ups forcing another call

Backport of #50467 to lts/1.108.x.
Cherry-picked from 478fb95d6b1 (litellm_allowed_tools_flat_tool_choice). Resolved: test imports merged with the line's, and the tests that need main's web search fixtures move to the line test commit.

* fix(openai): refuse an openai chat hook call the allowed_tools choice excludes

The line's OpenAI chat handler runs its own agentic hook loop instead of
the shared one main uses, so the picked exclusion check never reached
it. This checks the response before a hook runs, like the line's HTTP
handler already does after the picks, and answers 400 when the model
called a tool the choice leaves out. Chat calls with an allowed_tools
choice answer 400 on the line today, so no call that succeeds changes.

* test(tool-choice): adapt the picked tests to lts/1.108.x

The picked test files reach a few names the line does not have, so this
ports them to the line's code without bringing those features over.
The MCP response tests stub the line's own proxy_server imports, the
web search tests get main's perplexity_search fixture, and the chat and
Responses hook tests expect what the line does. An excluded chat hook
call answers 400, and native /v1/responses hooks run as before since
the line cannot end a Responses turn early

* fix(allowed_tools): stop the Responses web search follow-up forcing another call

Backport of #50467 to lts/1.108.x.
Cherry-picked from 08eb785ee22 (litellm_allowed_tools_flat_tool_choice). Resolved: adds main's _WEB_SEARCH_FUNCTION_CALL test constant, which came with #38885 and is not on the line, and wraps one long test line.

* fix(responses): send a malformed allowed_tools choice as given on lts/1.108.x

On the line, native /v1/responses with gateway MCP tools passes any
tool_choice through to the provider, with or without drop_params, and
providers that accept a malformed allowed_tools choice answer 200. The
picks answer 400 for it without drop_params and drop it under
drop_params, so this keeps the line's behavior. The choice reaches the
provider unchanged and the gateway enforces nothing for it, while a
choice that parses still gets the picked rewrite and enforcement

* fix(tool-choice): keep an allowed_tools type with a function as a named tool choice on lts/1.108.x

On the line, a tool_choice of type allowed_tools that also carries a
function passes validation and reaches the provider as a named function
choice, so Anthropic and other providers that read function.name force
that tool and answer 200. The picks treat it as a malformed allowed_tools
choice, which answers 400 without drop_params and drops the choice with
it. This keeps the line's behavior, so such a choice is not read as an
allowed_tools choice anywhere and goes on as the named choice it was

* style(tool-choice): format called_tool_names on lts/1.108.x

* fix(tool-choice): keep the caller's allowed_tools choice on agentic follow-up calls on lts/1.108.x

On main the agentic follow-up keeps the caller's allowed_tools choice
under a reserved kwarg that main lists among its loop control keys.
That list does not exist on the line, so the line's acompletion dropped
the key and a follow-up call could run a hook call the caller's choice
leaves out. acompletion now passes the key on when the caller sent it or
sent an allowed_tools choice, and leaves every other call as it was

* fix(types): widen untyped request dicts for the allowed_tools refusal on lts/1.108.x

The line types the hook loop's kwargs and optional_params as plain
dicts, so passing them to the picked refusal helpers added unknown
argument errors that main does not have. They are now cast to
Mapping[str, object] at the call sites, and the loop settings reader
takes a Mapping

The new cast import in the agentic loop would grow the banned-API
count, so the duplicate function-level cast import in
llm_http_handler.py goes, since the module already imports cast

* fix(anthropic): keep every non-streamed reasoning item for Messages clients and read a deployment's reasoning_summary in the keep check

Backport of #49076 to lts/1.108.x.
Ported from cadfe1d1798 (cursor/chatgpt-encrypted-reasoning-messages-1723) onto the line's pass_through/adapters layout.

* fix(anthropic): keep every non-streamed reasoning item for Messages clients on the line's bridge

This line's transform_request rewrites the logging call_type to responses, so the non-streamed reply read the Messages-client check after the rewrite and kept only the last reasoning item. The bridge handler now reads it before the request transform and passes it to transform_response, as the streamed path already does.

* fix(anthropic): log only the outcome of a turn sent again, and keep every reasoning item in Messages logs on the line

A /v1/messages turn whose replayed encrypted block the backend rejects is sent
once more without it. The rejected first attempt no longer fires failure
callbacks or releases its parallel slot and budget reservation, so only the
turn sent again is logged and counted.

Success logs for a Messages client now keep every reasoning item of a
non-streamed turn, matching the reply the client got.

* test(anthropic): type the parameters of the failure-recording test loggers

Backport of 3d53f0047d1 (#49076) to lts/1.108.x.

* test(anthropic): type the success logger and use a fixed token expiry in the bridge tests

* fix(anthropic): skip the SDK num_retries retry for an attempt that is sent again

* fix(anthropic): stop SDK retries from resending a rejected block or clearing the global num_retries

A transient 429 or 500 on a /v1/messages turn that carries a replayed encrypted
block was retried by an SDK call's num_retries loop, which sent the block again
until every retry was rejected. On async calls the loop then raised the first
transient error, so the turn failed instead of being sent again without the
block. The retry loop now stops at that rejection and passes it on, so the turn
is sent again once without encrypted blocks.

A rejected first try on a sync call also cleared the process-wide
litellm.num_retries, so later calls in the process were no longer retried. That
setting now stays as configured.

* fix(anthropic): stop a cancelled SDK retry from starting another call

The resent-failure retry predicate returned true for BaseException
subclasses such as asyncio.CancelledError, so a cancelled
acompletion_with_retries or aresponses_with_retries call could start
another provider call. Retry only Exception subclasses again, as
tenacity's default did, while still skipping a resent failure.

* test(anthropic): type the retry helper parameter in the cancellation test

* test(integration): backport main's Gateway.rows, Scenario.model name and MCP ack fix to lts/1.108.x

Backports test-only changes from main so the line's integration signal stops reporting stale helpers as failures.

Gateway.database_url and Gateway.rows come from #47213 (fc27dfdc7d), and the name keyword on Scenario.model comes from #48917 (ebf84f8649). Only those hunks of tests/integration/_support/client.py are taken. The rest of #47213 gives each owned proxy its own database and Redis, which none of the line's tests need, and the workers field from a later main change is left out.

The MCP progress and cancellation test wraps its upstream in _acknowledge_notifications_after_dispatch, from #49967 (b5952f243a). The helper is already on the line.

* fix(bedrock)!: backport #47429 deployment guardrailConfig on /bedrock pass-through routes to lts/1.108.x

The router-model pass-through dropped a Bedrock deployment's guardrailConfig, so converse, converse-stream, invoke and invoke-with-response-stream reached Bedrock unguarded while /v1/chat/completions on the same deployment was blocked. The signer now sends it the way Bedrock reads it, in the body for Converse and as the X-Amzn-Bedrock-Guardrail* headers for Invoke, replacing any guardrail the caller sent

Adapted to the line, which does not have #47040. The guardrail headers are merged through merge_bedrock_invoke_headers without the request metadata header, and the unit tests drop the request metadata assertions and the identity argument that only #47040 needs

* refactor(bedrock): drop the unused converse URL helper and cover a trailing-slash converse pass-through

* test(e2e): repin the Together reasoning replay backend to MiniMax-M3.1-Flash

MiniMax-M3 reached its 2026-11-06 deprecation date in the cost map, which names MiniMax-M3.1-Flash as its successor

(cherry picked from commit 90f7ab6fe6837152b21617c8cb7dc73a541c42e9)

* fix(sdk): backport #45961 to lts/1.108.x

completion() loaded the MCP gateway handler for any request with tools,
and the handler pulls in mcp 2.x only code, so tool calls failed on
installs with mcp 1.x (google-adk 1.36.1) or no mcp at all

Cherry-picked from 783cf06f31. Only conflict was import context in
litellm/responses/main.py

(cherry picked from commit 783cf06f31e55e8f7ab84c2d7c708b0d90e68001)

* fix(router): serve a team's wildcard deployment before a proxy-wide wildcard (#48490)

Backport of #48490 to lts/1.108.x.
Cherry-picked from 76d001a7c06d5dbf93f9191b247db0ef981b6c66 (main). The line has no wildcard_routed_models helper and no get_models_by_pattern, so only wildcard_route_deployments is changed.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(videos)!: keep model_id in proxy video ids so per-model keys resolve on status/content (#44614)

Backport of #44614 to lts/1.108.x.
Cherry-picked from ba61ecdf570c91a2409560138170ff9ab1fe7ad7 (main). The line has no splits_stream_timeout on _update_kwargs_with_deployment, so only the _video_call_pin wrapping is added around deployment selection. The line has no litellm/llms/base_llm/videos/async_task_utils.py, so its _id_safe_name dedupe is applied to the dashscope video transformation that holds the same helper on this line.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* chore: bump litellm 1.108.3 -> 1.108.4

litellm 1.108.3 already shipped, so the next release off this line is 1.108.4

* fix(proxy): check s3 URIs inside encoded file ids and on queued chat completions

The s3 media check now decodes model-embedded and unified file ids, since
completion() turns them back into the raw s3 URI they carry. The
/queue/chat/completions endpoint skips common request processing, so it now
runs the same check. The media walk goes level by level instead of
recursing, which the recursive_detector code-quality step requires.

(cherry picked from commit 5b45c632c57fd46b9dda537b694edcda2e0f41d3)

* fix(anthropic-messages): apply additional_drop_params before the unsupported param checks

* fix(proxy): let a key send managed file ids it may read and refuse s3 sources hidden in model_file_id_mapping

The s3 media gate refused every LiteLLM managed file id whose upload sits under the
managed prefix, even when the key's own user or team created it. It now asks the
managed files hook which unified ids the key may read and skips only the objects
those ids embed. A forged or unowned id, or a proxy without the hook, still gets a 403.

The gate also reads the provider file ids in a client-supplied model_file_id_mapping,
so an alias can no longer point a non-admin request at an unlisted or managed object.

Markdown documents (.md, .markdown) now map to Bedrock's md document format, so an
s3 Markdown source without an explicit format no longer fails with an unknown media type.

On lts/1.108.x the gate still walks the body before it reads the key role, so callers that pass a
specced UserAPIKeyAuth mock keep working, and it reads self.data and general_settings directly
since the line has no raw_request_fields.

(cherry picked from commit 37f085c966dd83e84b646eb3acbdfbaef7b6b0db)

* fix(mcp): refuse a hook call the allowed_tools choice excludes on every surface

The line has no terminal-response path outside Anthropic Messages, so the check skipped /v1/responses and streamed hook loops and the excluded call ran. It now raises AgenticLoopToolChoiceError there too

* fix(mcp): scope each MCP entry to its own allowed_tools and keep the allowlist on follow-ups

A label now covers only the tools its own allowed_tools lists, so a second label on the same server no longer widens it. Responses MCP follow-ups, streamed or not, keep an allowed_tools choice in auto mode instead of dropping it. The new Responses tests fake only the upstream MCP listing, so LiteLLM's own discovery runs

* fix(agentic): answer a 400 when an allowed_tools choice excludes a hook call on /v1/responses

The line cannot end a Responses turn early, so the refusal was re-raised as a
plain error and reached clients as a retryable 500. It now answers the same 400
the chat path gives for an excluded call. The stream path still raises the
safety error its iterator catches.

* fix(mcp): match an entry's allowed_tools against the tool name the gateway lists

A server with a display name override lists the display name, and the listing
filter matches allowed_tools against it, but the label scope only checked the
original name, so no spelling worked. The scope now also accepts the listed
name and its unprefixed part, like the listing filter. Tests now cover the
whole gateway and toolset entries and a display-named tool.

* fix(proxy): keep inline tool-result video dropped and let an admitted client AWS identity skip the s3 bucket list

A tool result forwards a video to Bedrock only when it is an s3Location. An inline
base64 video is dropped with a warning, as it was before this change, since Converse
rejects video in a toolResult block

A non-admin key that sends an AWS identity its deployment admits through
configurable_clientside_auth_params (aws_role_name, aws_web_identity_token or
aws_profile_name) skips the bucket list, because Bedrock then reads the object with
that identity. The managed-prefix 403 still applies

The check now skips the body walk when no string starts with s3:// and no file_id or
model_file_id_mapping key is present, which keeps large image bodies cheap

Adapted for lts/1.108.x. The per-frame check on WS /v1/responses is not ported,
because this line has no Responses WebSocket frame guard to hook it into. The gate
keeps this line's admits_s3_bucket allowlist and its order of walking the body
before the admin role check

(cherry picked from commit 6662cb34d768bd68a7dc34ea27c363a1bd7f6578)

* feat(decisions): support Vercel AI Gateway decision models

Backport of #50642 to lts/1.108.x.
Cherry-picked from bdd017e908e2380de83b059b08c9363431227666 (mishdotdev:vercel-ai-gateway-decisions).
Adapted to the line: the line registers decisions configs in its own if-chain and lazy-import tables, and its OpenAI decisions config has no resolve_credential hook, so only resolve_api_key is overridden.

* test(decisions): cover Vercel AI Gateway dispatch through the proxy

Backport of #50642 to lts/1.108.x.
Cherry-picked from dd1057b018f8bce2408627a15ea7e7a65c2e33b1 (mishdotdev:vercel-ai-gateway-decisions).
Adapted to the line: the new test is appended to the line's own copy of the test file, whose tail differs from main's.

* feat(decisions): add Vercel AI Gateway cost map rows for Jev

Backport of #50642 to lts/1.108.x.
Cherry-picked from 3f9539201cef70aa965fc494fbdb3179b6560c1f (mishdotdev:vercel-ai-gateway-decisions).

* fix(decisions): bill Vercel AI Gateway decisions at the charge Vercel reports

Backport of #50642 to lts/1.108.x.
Cherry-picked from 7c40b75f5657ec067f9a6fe2c7c91f8662c81a78 (mishdotdev:vercel-ai-gateway-decisions).
Adapted to the line: its decisions usage is never None, so the None guards are dropped, and the resolve_credential override stays out as in the first pick.

* fix(decisions): bill Vercel gateway charges with margin and BYOK, forward providerOptions

Backport of #50642 to lts/1.108.x.
Cherry-picked from 1f50a7c91f5032cbd350ab71af204245f2c640a7 (mishdotdev:vercel-ai-gateway-decisions).
Adapted to the line: the line has no upstream_usage_cost billing path (main got it in #48953), so the reported charge still goes out as the line's response-cost header and the operator discount and margin do not apply to it there, the same as OpenRouter decisions on the line. The image check is resolved once per request beside the line's box-question check, and the tests read the billed cost the way the line bills it.

* fix(proxy): check s3 media on every Responses WebSocket frame on the LTS line

The managed Responses WebSocket handler calls litellm.aresponses once per
response.create frame, and the HTTP s3 media check only saw the first frame as a raw
JSON string. A non-admin key could send an s3 object from an unlisted bucket, or one
under LiteLLM-managed storage, to Bedrock over WS /v1/responses

The WS route now hands the handler a frame check bound to the connection's key,
general_settings, managed files hook and router. The handler runs it on the params it
is about to forward for every frame, the first one included, and a refused frame gets
an invalid_request_error frame with the 403 message while the socket keeps serving
later frames

* fix(decisions): stop forwarding caller providerOptions to Vercel and send Jev images

Backport of #50642 to lts/1.108.x.
Cherry-picked from c8122bc6a5305fd8ce0bc3c1d534581d4dd1227a (mishdotdev:vercel-ai-gateway-decisions).
Adapted to the line: decisions/call.py goes back to the line's own version, since the line never had the per-model support record main edits here, and the discount and margin test this commit touches on main is not on the line.

* fix(decisions): report provider charges on the cost header and read Vercel's cache split from the serving provider

Backport of #50642 to lts/1.108.x
Cherry-picked from ec26925103f82742866219bd73d19f88cc3de84e (mishdotdev:vercel-ai-gateway-decisions)

The Jev 1.13.0 and 1.14.0 rows record their image probes

Conflicts resolved to main's result. The call.py hunk is dropped because the line already reports provider charges on the response-cost header. The proxy test keeps only its paid call, since the line's proxy drops a zero response-cost header for every provider

* fix(proxy): let a client AWS identity skip the s3 bucket list only when Bedrock signs with it

An admitted aws_role_name, aws_web_identity_token or aws_profile_name now skips the
bucket list only when it decides the credentials get_credentials picks, on every
deployment of the model group. A web identity token without a role and a session
name does not, since get_credentials then ignores it. A profile does not when the
deployment or the environment sets a role, since the role branch runs first. In
those cases Bedrock still reads with the proxy's credentials, so the bucket list
applies

BaseAWSLLM.identity_choosing_params mirrors the branch order of get_credentials, and
both read the same AWS_* environment fallbacks through one helper

Ported to lts/1.108.x, where the model group is read with Router.get_model_list

* fix(mcp): match an entry's allowed_tools only against a server's own prefix, and a tool no server resolves only by its exact name

* fix(proxy): keep the s3 bucket list for non-admin keys that send a client AWS identity

A client AWS identity field does not prove that the caller can read the bucket. A
role or profile name picks credentials the proxy holds, and Bedrock reads the object
with them. So the bucket list now applies to every non-admin s3 media part, whatever
AWS identity fields the request sends. allow_client_side_credentials: true still
turns it off

This removes BaseAWSLLM.identity_choosing_params and the router lookup that only the
skip needed

Ported to lts/1.108.x

* fix(cost): bill transcriptions by the seconds the provider reports

Line port of the usage.seconds billing slice onto lts/1.108.x: normalized_audio_duration_seconds and _get_transcription_usage_duration from #35600 (ecb8ef5ca8), and the provider-seconds-first _transcription_duration_for_cost from #50727 (dfb1aac8b1), with their unit tests. The rest of #35600 stays on main.

* fix(transcription): treat libsndfile's unknown frame count as no duration

Backport of #50842 to lts/1.108.x.
Cherry-picked from e6a0534785 (litellm_transcription_unknown_frame_count).

* refactor(transcription): inline the unknown frame count check

Backport of #50842 to lts/1.108.x.
Cherry-picked from b6d25f2752 (litellm_transcription_unknown_frame_count).

* fix(transcription): read the frame count once to keep the type gate flat

Backport of #50842 to lts/1.108.x.
Cherry-picked from 54dcd9230f (litellm_transcription_unknown_frame_count).

* test(transcription): annotate the new passthrough test's locals as Final

Backport of #50842 to lts/1.108.x.
Cherry-picked from eb0f251b47 (litellm_transcription_unknown_frame_count).

* feat(openai)!: honor per-deployment workload identity on non-chat routes (#39966)

Backport of #39966 to lts/1.108.x.
Cherry-picked from b39eadcb8228e05b76506df78fa2723628494669 (main).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(mcp): refuse a tool whose display name only looks like an allowed name, and let the chat follow-up answer

An MCP entry's allowed_tools now matches a tool only by its exact listed name or a spelling routing
accepts for its real name, so a display name that carries the server's own prefix no longer passes for
another tool. The chat MCP follow-up keeps an allowed_tools choice in auto mode, so the model can answer
with text after the tool ran.

* chore: bump litellm 1.108.4 -> 1.108.5

litellm 1.108.4 already shipped, so the next release off this line is 1.108.5

* fix(mcp): match a toolset label's tools by exact native name

A toolset label served any tool whose name a routing spelling of a granted name matched, so a toolset granting the literal name "server-tool" also served the real tool "tool" that only another toolset grants. It now serves a tool only when the toolset grants its exact native name, the same check tool_is_granted uses when the gateway lists tools

* feat(bedrock): search knowledge bases by image and return image hits

vector_stores.search and asearch take a query_image (base64 jpeg, png, gif or webp), and query is optional when it is sent. Bedrock sends it as an IMAGE retrievalQuery, and a caller's own retrievalQuery in extra_body still wins

Bedrock IMAGE hits now come back as image content items instead of being dropped. The media type comes from the source file mime type metadata, then the data URI label, then application/octet-stream

A request with both query and query_image, with neither, or with a malformed image gets a 400. So does query_image on a provider without image search, unless drop_params is on. The proxy accepts query_image in place of query on /v1/vector_stores/{id}/search

Spend logs redact image data when prompts are not stored. Emulated file_search skips image-only hits, RAG rerank maps its indices to the text documents it ranked, and the dashboard tester renders image hits

(cherry picked from commit 55587c70122fc0fa4369cc23886e753a91b47ee0)

* fix(vector-stores): keep image hits to image searches and reject a caller retrievalQuery

Port of the main branch change. Text searches return the same text hits as before, image hits come back only for query_image searches, a caller retrievalQuery answers 400 or drops under drop_params, a file_search tool carrying query_image searches again, and a non-string query next to an image answers 400

On this line the typed views use as_str_mapping and a local list helper, since decoded_json_object and as_object_list are not on lts/1.108.x

(cherry picked from commit 65a7206199c4c51b46084f8417bf7235d33fd378)

* fix(compresr): let the retrieve call run under an allowed_tools choice on lts/1.108.x

The line's CompresrGuardrail did not list compresr_retrieve in server_fulfilled_tool_names, so the allowed_tools exclusion check counted the model's retrieve call as excluded and the request answered 400. Main has declared it since #49227, and this adds the same attribute with a regression test

* fix(usage): restore per-user spend breakdown on the user aggregated route (#49464)

Backport of #49464 to lts/1.108.x. Cherry-picked from 639625d6791e9236cb12e72790fdf7f00fc55323 (main).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: preserve spacing around the user metadata helper

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(translation): expect encrypted reasoning in message responses (#50576)

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 7617e66acfe1f3f9bb2984646c7da7c2f7d9db1b)

* test(integration): decode video ids with the product decoder in the callback delivery test

Ports only the tests/integration/observability/test_callback_delivery.py hunk of #47600. Video ids on this line now carry a ;deployment_id: suffix after #50693, so splitting on video_id: kept the suffix. The shares_worker_state pytestmark from that hunk's context belongs to a change not on this line and is left out

(cherry picked from commit e78f7b4602c15a5328f6f211c4bc9f3d664e1d50)

* test(integration): let an owned proxy opt into a private database and Redis

Ports the harness part of #47213 (process.py, workers.py, the remaining client.py hunks and its unit tests) so owned_proxy and owned_proxy_process accept state=OwnedState.PRIVATE and boot on a scratch database and their own redis-server, and Scenario cleanup checks read the database the proxy writes to.

Adapted for this line. Main makes private the default and marks 189 test files with shares_worker_state to keep them on the worker's state. This line keeps the worker's state as the default, so no existing test changes behavior and only callers that pass state=OwnedState.PRIVATE go private. The isolated_gateway rewrite and the conftest marker plumbing are left out, and the unit tests cover the shared default plus the explicit private opt-in

(cherry picked from commit fc27dfdc7d9be704a1c5bffb9c954caeae9dc886)

* test(integration): run the body upload disconnect test on a private database

Ports only the tests/integration/observability/test_guardrail_effects.py hunk of #49310. The test asserts the only spend row is its own control call, so on the shared worker database it picked up rows other tests wrote

(cherry picked from commit fbd126e5182040a5ed8b97d54d41b5febc94452b)

* test(compresr): annotate the allowed_tools choice test's locals as Final

* test(integration): give each kill-burst its own prompts so cached control replies cannot stand in for late traffic (#50569)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 0d0bf8f75f63a9c76ab75d121cdd6b7f498f2607)

* fix: make scheduled key, user, and team spend resets idempotent (#50298)

Backport of #50298 to lts/1.108.x.
Cherry-picked from ac08eb566314a2dec9f73ede0bb8c687118b5608 (main).

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): add execute_raw to the PrismaBatch protocol

Prerequisite for the #50298 backport to lts/1.108.x, which queues guarded raw spend resets on the batch.
Hand-ported from 24a7bf6af728272eca2ba3277a2f3cdfa7e60863 (#48260, main).

* fix(azure): accept explicit v1 Responses bases (#48072) (#48118)

Backport of #48118 to lts/1.108.x.
Hand-ported from 96abce842b (main): the line lacks #46377's api-version resolution helpers.

* fix(azure): send no api-version on Foundry project /openai/v1 Responses bases

Backport of the main fix on branch litellm_azure_responses_project_v1_api_version to lts/1.108.x.
Cherry-picked from 2a8cdecb15 and adapted to the line's get_complete_url.

* fix(vector-stores): redact query images and keep store search params out of image checks

(cherry picked from commit 0574a8e11965c95dac58ffe037064ff43bf6846b)

* fix(mcp): backport #50717 to lts/1.108.x

Cherry-pick of e6db6206d1 with module paths moved to litellm/proxy/_experimental/mcp_server.

* fix(responses): keep unset-effort gpt-5.4/5.5 tool calls on chat completions (#50968)

Backport of #50968 to lts/1.108.x.
Cherry-picked from d47c03175bba41a39c4c3f8a947e28938708eef2 (main).

Line adaptation: the line has no bridge_reasoning_effort helper or deployment-pinned
routing mode, so the bridge-flag tests pass the effort directly and skip the mode pin.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(vertex_ai): bill gemini image edits by token usage (#51038)

Backport of #51038 to lts/1.108.x.
Cherry-picked from 53e1e9b87b36dabed967b17338948535020b7abc (main).

Line adaptation: the line has no map_vertex_image_size or the Gemini image-size tests, so only
the usage test and the token-usage response path come across.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(mcp): backport #51065 to lts/1.108.x

The connect check regression test mocked the credential reader, so a broken
stored grant still passed. It now saves the grant with the real writer into an
in-memory table and lets the connect check read and decode it.

Cherry-picked from 478d9bf5d2 on main, with module paths moved to
_experimental/mcp_server.

* fix(vector-stores): redact images nested in extra_body and keep a store's extra_body retrievalQuery out of searches

(cherry picked from commit c99fd3631b256caf20bdc5eab530226d02be0b80)

* fix(responses): read reasoning_effort from extra_body for the bridge gate

Minimal prerequisite for #50968 on lts/1.108.x: the bridge_reasoning_effort and
str_keyed_mapping helpers from 897dda7920 (#46263, main), so a reasoning_effort sent
in extra_body still bridges gpt-5.4+ function-tool calls now that an unset effort
stays on chat completions.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(vector_stores): keep a caller's image query through store and router params

A deployment's retrievalQuery no longer reaches a routed search, a caller's query fields survive a store's own extra_body, and an extra_body image stops before the provider. file_search forwards rewrite_query, both retrieval query spellings are redacted, and the cost error stops echoing the response when message logging is off

(cherry picked from commit c65634d4ade59d5c06dabacb946b77161aa79365)

* feat(azure_ai): support gpt-image edits on Azure AI Foundry

Foundry hosts gpt-image deployments on the same /openai/deployments/{deployment}/images/edits route as Azure OpenAI, but the azure_ai image-edit factory only knew MAI and FLUX, so gpt-image-2 and the gpt-image-2.5 models raised a ValueError before any request was sent

Reuse AzureImageEditConfig for the request, URL, and multipart handling, and resolve the api_base and credentials with the azure_ai helpers

Co-Authored-By: AaronHowell <111272993+AaronHowell@users.noreply.github.com>
(cherry picked from commit 4c29e1846a7de81bc986f23058c91816be2e5581)

* fix(azure_ai): default gpt-image edits to an edit-capable api-version

Foundry gpt-image edits now fall back to 2025-04-01-preview when no api_version is set, since the shared Azure default 2025-02-01-preview answers 404 on /images/edits. The config returns merged headers instead of updating the caller's dict, and the tests check the request each gpt-image model sends

(cherry picked from commit 233a0d99f12c939f1050b67324e83aeb0c42dc23)

* fix(azure_ai): ignore the Azure OpenAI api-version env for Foundry gpt-image edits

The proxy CLI always sets AZURE_API_VERSION to 2025-02-01-preview, which
Foundry answers with 404 on image edits. gpt-image edits now read only
litellm_params, AZURE_AI_API_VERSION, and litellm.api_version before the
2025-04-01-preview default, matching the other azure_ai edit configs

(cherry picked from commit c93fd388d4d34e865b426b1d53297f469734fad4)

* fix(azure_ai): route custom Foundry deployments, require a Foundry api_base, and honor caller auth for gpt-image edits

A deployment name the edit factory does not recognize now uses the gpt-image route instead of raising, since Foundry deployment names are free-form. A gpt-image edit with no Foundry api_base raises like the MAI and FLUX configs instead of borrowing AZURE_API_BASE. The shared edit handler passes the call's extra_headers to validate_environment, so a caller's api-key or Authorization header is sent alone

(cherry picked from commit 6be34701e6bc69d43659e5b9068cdd149cf5c9cf)

* fix(azure_ai): keep the shared edit handler unchanged and send caller auth headers like azure_ai chat

(cherry picked from commit 31348e4c5f90c85fbf4e981e73ccb258eea9431e)

* fix(cost): leave image search responses out of the cost error text

(cherry picked from commit b892162eb3dfc7c7d8bf24d54130ee9e794832c3)

* fix(vector_stores): accept line-wrapped base64 in query_image data

Bedrock takes inlineContent wrapped with \n or \r\n line breaks, as plain base64 writes it, so the check ignores only those before decoding and the data goes to Bedrock as sent

(cherry picked from commit c2cad843b07609f3d216a46db6150c186568d595)

* chore: bump litellm 1.108.5 -> 1.108.6

litellm 1.108.5 already shipped, so the next release off this line is 1.108.6

* fix(usage): keep spend when metadata lookups hit database failures (#50253)

* fix(usage): tolerate entity metadata database failures

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(usage): keep spend when metadata lookups hit database failures

Treat transport errors and the query engine crash on a closed connection as database
failures in the key, user and guardrail lookups of the aggregated, keys, users,
model_top_keys and cache_leakage_keys routes, and keep prisma out of module-level imports
so a proxy install without prisma still imports the usage endpoints.

* fix(usage): fall back only on database outages, on every daily activity route

Data-layer Prisma errors such as a rejected query or a missing table return 500 again, a key whose details failed to load reports key_exists null instead of false, and the non-aggregated daily activity routes keep spend when the key or entity metadata lookup hits an outage

* fix(proxy): skip the key metadata lookup when the daily rows carry no keys

* fix(usage): keep the guardrail breakdown fallback for any Prisma error

A missing guardrail usage table or column made the Usage call return 500 after the outage-only narrowing. The guardrail lookup now falls back on outages and on any Prisma error, as it did before this PR

* fix(usage): keep spend when the team, organization, customer, or agent name lookup drops

---------

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 5d66f2d8ff55378ee01c0cb04f3193330dc09e83)

* fix(ci): install tzdata so zoneinfo tests pass on runners without legacy tz aliases (#51057)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit ebd5a15b22ba012d2f5a5ee654afc93cd51add5e)

* fix(baseten): forward reasoning_effort to Baseten Model API (#40152)

* fix(baseten): forward reasoning_effort to Baseten Model API

Baseten's Model API accepts a top-level reasoning_effort parameter and
validates it server-side (https://docs.baseten.co/inference/model-apis/reasoning),
but BasetenConfig.get_supported_openai_params did not list it, so LiteLLM
silently dropped it when drop_params=True and raised UnsupportedParamsError
otherwise.

Add reasoning_effort to the supported params so map_openai_params forwards
it verbatim, mirroring the hosted_vllm and deepseek providers. Baseten
returns a clear 400 for values outside a model's supported set and ignores
the parameter on non-reasoning models, so verbatim passthrough is safe for
the whole catalog.

[Claude_Code]

* fix(baseten): forward reasoning_effort to Baseten Model API

Baseten's Model API accepts a top-level reasoning_effort parameter and
validates it server-side (https://docs.baseten.co/inference/model-apis/reasoning),
but BasetenConfig.get_supported_openai_params did not list it, so LiteLLM
silently dropped it when drop_params=True and raised UnsupportedParamsError
otherwise.

Add reasoning_effort to the supported params so map_openai_params forwards
it verbatim, mirroring the hosted_vllm and deepseek providers. Baseten
returns a clear 400 for values outside a model's supported set and ignores
the parameter on non-reasoning models, so verbatim passthrough is safe for
the whole catalog.

---------

Co-authored-by: ryan-crabbe-berri <ryan@berri.ai>
(cherry picked from commit 13335266f59a822dcafaadf7329c6a938867c265)

* fix(baseten): list current Model APIs instead of retired 2023 deployment IDs (#46945)

* fix(baseten): list current Model APIs instead of retired 2023 deployment IDs

`baseten/*` wildcard expansion and `/v1/models` read a hardcoded set of
three 2023 deployment IDs (Falcon 7B / WizardLM / MosaicML) that no longer
exist, while the model cost map already carries current Baseten entries.

- Populate `baseten_models` from the model cost map, like fireworks_ai.
- Add `BasetenConfig.get_models()` against the Model API `/v1/models`
  endpoint and register it in `ProviderConfigManager.get_provider_model_info`,
  so `check_provider_endpoint: true` returns the live catalog.
- Remove the retired deployment IDs from `constants.py`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(baseten): mark retired Model APIs deprecated and skip them in listings

15 Baseten entries in the model cost map are no longer servable: the Model
API returns 410 "model version ... has been deprecated" (DeepSeek-V3.1
returns 400 deactivated), and none appear in `inference.baseten.co/v1/models`.

- Set `deprecation_date` on those entries (kept for spend tracking).
- Skip entries past their `deprecation_date` when building `baseten_models`,
  so `baseten/*` expansion only lists models that still serve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(baseten): assert the custom api_base model listing on the returned models

The custom api_base test only inspected the patched client's call args, which trips the
TQ002 mock-echo gate. Serve the custom URL with respx and assert on the models that come
back instead, so a wrong host or a broken parse both fail.

* fix(baseten): drop newly retired models on cost map reload and fake discovery at the HTTP boundary

A cost map refresh only ever added to the Baseten set, so a model that gained a past
deprecation_date after boot stayed listed under baseten/* until restart. Discard it on reload.

Tests now serve the catalog with respx instead of patching our own HTTP client, the
isinstance registration test is gone since the get_valid_models test already proves
discovery end to end, and new test locals carry Final.

---------

Co-authored-by: AlexKer <AlexKer@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: ryan-crabbe-berri <ryan@berri.ai>
(cherry picked from commit 3eeee3e76118783671bd7c9dd44a192eedf917ad)

* fix(router): route decisions calls only to deployments whose provider supports decisions (#48175)

* fix(router): route decisions calls only to deployments whose provider supports decisions

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(router): account for indirect route helper coverage

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(router): pin the chat leg so the mixed-group check is deterministic

Weights pick the Bedrock leg for chat instead of relying on simple-shuffle landing on both legs. The route filter now passes the candidate list through unchanged in type, so the pre-existing selector lines lose their pyright ignores

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: joshua <joshua@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 4710c3b30e5c1459dbb11a060ad733ee06f06c18)

* fix(responses): keep every MCP tool round in streaming follow-up input (#47698)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: ryan-crabbe-berri <ryan@berri.ai>
(cherry picked from commit f1795e6d447a4e5a3660de0d2fde5e1f44f52929)

* fix(responses): skip failed spend-log turns when rebuilding a session from previous_response_id (#48647)

* fix(responses): skip failed spend-log turns when rebuilding a session from previous_response_id

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): guard the failed-turn status read and annotate the regression test locals

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>
(cherry picked from commit df9091deb666f0d689c7df01056374569019c03e)

* fix(responses): reject or drop Responses params the chat completions bridge cannot translate (#48655)

* fix(responses): reject or drop Responses params the chat completions bridge cannot translate

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): keep additional_drop_params working for Responses fields the bridge cannot translate

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* Update litellm/responses/main.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* style(responses): drop the blank line ruff format rejects after the dataclass header

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>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
(cherry picked from commit e32d8a4d03f62ca0ec123e0a9377f6be32653bc0)

* fix(vector_stores): drop rewrite_query false from the chat file_search tool

False asks for the default search every store already runs, and MongoDB
rejects the field outright, so forwarding it made a MongoDB chat lose the
store's context for a no-op flag. True is still forwarded.

(cherry picked from commit ee74a39a776)

* fix(responses): serialize sequence_number on every bridged streaming event (#44944)

* fix(responses): serialize sequence_number on every bridged streaming event

* test(responses): cover sequence_number on bridged streaming events

* fix(responses): read undeclared fields through dict accessors and number guardrail block continuations

* fix(responses): scope dict reads that see undeclared fields to Responses stream events

Moves the extras-aware __getitem__, get, __contains__ and items from the
shared response base onto a new base for the 37 stream event classes, so
usage, Gemini, Interactions and moderation objects keep reading __dict__
and Gemini responses keep _hidden_params out of .get

* fix(router): renumber Responses stream events only after a fallback takes over

A stream that never falls back now keeps its provider's own sequence numbers, repeats included, so a starting_after resume still matches them. After a fallback the wrapper continues above the highest number the client saw

* fix(guardrails): keep Responses stream numbers unique when LLM Shield flushes held text

The restorer's flush copied the last delta and kept its sequence_number, so a
native stream repeated a number and a bridged stream sent the flush unnumbered.
A flush now takes the done event's slot and later events move up by one, and a
stream the provider never closed numbers its flush after the last event.

Also pins the created_at in the streaming iterator test fixture instead of
reading the clock.

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
(cherry picked from commit 6f3251c7e31fb6fed73a786becc6c62f2df56ce7)

* fix(decisions): keep the Vercel AI Gateway key off the OpenAI credential fallback on lts/1.108.x

The line gained the Decisions resolve_credential hook in the backport of #39966 after this branch was cut, so the Vercel provider would inherit OpenAI's fallback to OPENAI_API_KEY. Take main's override from #50642, which returns the gateway key as is.

* test(e2e): remove the secret manager suite (#51241)

The secret manager lanes ran the proxy against a Vault dev container and a
Conjur container that we start ourselves, so nothing in them needed a real
third-party service. They have not run a single test since late October,
because the co-located proxy cannot boot in the lane pod, and they were
soft_fail outside the promotion gate, so they only added noise.

The AWS test in the folder was skipped on every lane, since no aws lane
ever existed.

The four coverage registry rows go with the tests, because the registry is
the e2e denominator and this behavior belongs in the integration tier if it
gets covered again. The Vault and CyberArk clients keep their unit tests.

(cherry picked from commit 587902becf7d48d843befca9d7ea359a216e39d7)

* fix(proxy): stop request body fields from conflicting with admin-set deployment fields

Six fields that also configure Azure sign-in on a deployment (tenant_id, client_id, client_secret, azure_username, azure_password, azure_scope) could be set in a request body, where they conflicted with the values an admin set on the deployment

They are now refused at the body root, in extra_body and in litellm_embedding_config unless an admin opted in with allow_client_side_credentials or configurable_clientside_auth_params. Credential fields and user_config deployments also refuse values in the os.environ/ and oidc/ format, which only admin config uses. Deployment management routes are unchanged

Routes where these names are the API's own fields keep accepting them. That covers client_secret on the realtime transcription_sessions routes, client_id and client_secret on the MCP server OAuth form and on /introspect, and all six as metadata tags

Co-authored-by: Oliver Jensen <oliver@berri.ai>
(cherry picked from commit 6ba6b041e517bd424e8fb4d75aa724962abe289d)

* test(proxy): drop the two request body classifications the field ban removed

client_secret and azure_password are no longer accepted in a request body by default, so the registry's list of credential params a client may send no longer includes them

(cherry picked from commit 2b7e860982d0bdd60f7b5f3ec88d60ce871c3c78)

* test(proxy): import Mapping for the backported request body tests

* fix(proxy): check user_config search_tools for admin-format values too

The source change checks user_config search_tools entries as well as model_list and default_litellm_params. This line's walker skips search_tools, so the backport walks them for this check

* fix(vertex_ai): bill gemini image text, thinking and priority tokens at their own rates (#51017)

Backport of #51017 to lts/1.108.x.
Cherry-picked from 461b56b14b2a024ff73e59f56c01db169dfb902f (main).
Conflicts resolved: vertex_gemini_transformation.py import block (the line does not import map_vertex_image_size) and test_image_usage_transformation.py (the line lacked the ValidationError import and the rejects test, both taken from the pick).

* feat(gemini): file-backed batch jobs on /v1/batches with output download and spend tracking (#51032)

Backport of #51032 to lts/1.108.x as the prerequisite of #51279.
Cherry-picked from a0f2562088 (main).
Conflicts resolved: http_handler.py (the line has no _send_streaming_get, so only the anchor_handler_to rename was taken, including the line's own call site), tests/unit/batches/test_batch_utils.py and test_main.py (the line lacks the hosted_vllm batch tests the pick was formatted next to, so only the new gemini tests were taken). Line adaptation: join_api_base and _strip_trailing_slashes_keeping_the_scheme copied from main's url_utils (#47535) because the gemini files transformation needs them and the line never received that helper.

Line adaptation: the three join_api_base call sites validate GeminiModelInfo.get_api_base through TypeAdapter(str), because the line still annotates that helper as str | None while main returns str, so the type gate would otherwise count three new reportArgumentType errors.

* fix(gemini): attribute /gemini batchGenerateContent batches to the calling key (#51279)

Backport of #51279 to lts/1.108.x.
Cherry-picked from 801e139c35af5eca132e8761cb11be19621218c4 (main).
Conflicts resolved: gemini_passthrough_logging_handler.py import block (the line keeps its import re) and test_gemini_passthrough_logging_handler.py, where the line lacks the gemini pass-through pricing probe tests, so only the new batch tests and their asyncio and base64 imports were taken.
Line adaptation: gemini_deployment_id reads deployments through llm_router.get_model_list(model_name=...), the line's name for what main calls llm_router.registry().deployments(model_name=...).

* fix(bedrock): check OpenAI vector store filter values per operator and keep nested groups within the AWS limit

AWS in and notIn take only a non-empty list of strings, so an in or nin list holding a number now goes out as orAll of equals or andAll of notEquals, and a one-item list as a single equals or notEquals

Each OpenAI filter now refuses keys it does not define and checks its value by operator: eq and ne take a scalar, gt, gte, lt and lte take a number, in and nin take a non-empty list. An empty filters object is invalid too. Each of these answers 400 before any AWS call, or is dropped under drop_params, where before it reached AWS and failed there or, for a stray key, was silently ignored

AWS rejects a RetrievalFilter nested more than 2 levels deep, so a group whose member is the same kind of group, written by the caller or made from a numeric in or nin, now takes that member's items. A mix of and and or nested deeper than AWS allows still fails at AWS

_aws_group_members joins the recursion detector's ignore list, since it walks only a validated filter that pydantic-core stops at 255 levels

Backport to lts/1.108.x.
Cherry-picked from b15ac0fe6b and 2232dba0db (litellm_bedrock_vector_store_openai_filters), whose main PR follows as the forward-port.

* fix(azure_ai): send reasoning_effort to Foundry Kimi K3 and keep its reasoning_content

Foundry models whose loaded catalog row declares reasoning_effort_levels now take reasoning_effort as a level string, rounded up to the nearest declared level, and an effort object is unwrapped to its level. Fireworks-hosted FW- models keep reasoning_content in replayed history, so Kimi K3 can read back what it decided in its earlier thinking. The gate reads the catalog as loaded, so levels a router copies onto the shared row for one deployment do not open reasoning_effort for an undeclared sibling

* fix(responses): preserve mixed reasoning and answer deltas on lts

Partial backport of #46754 to lts/1.108.x. Source merge commit a8113b0dd721804c752a6f1952367fb642205224. Preserve the reasoning/answer split only, excluding the unrelated Anthropic compaction changes.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): look up managed file ids only when they can change the s3 refusal

(cherry picked from commit 0043e3020f5258d6542cad2031f70b2928b89101)

* fix(bedrock): check every file id field, skip MCP tool calls, accept registered S3 media types

(cherry picked from commit 2b13898be4959f51255d7a40978cc6515a522a8a)

* fix(proxy): refuse unlisted s3 media on the rag query and adapter routes

(cherry picked from commit 1d85ba2c1de440543a38b1ca58f0636d8c1bb631)

* style(proxy): format the merged collections.abc import

(cherry picked from commit 91bb8946180b52a708944a7c939e337704834d0e)

* fix(proxy): walk tuples when checking s3 media and skip plain number lists

(cherry picked from commit 5d8f25696341df2acf559ada53ef66ff53dd448d)

* fix(proxy): skip numbers when walking a request body for s3 media

A body with large token-id lists and any s3:// string or file_id key made
the full walk build a node per number, taking seconds per request. The walk
and its prefilter now skip int, float, bool and None values.

(cherry picked from commit 57e73a8f7de294abbc90bef55bdd58acb30f24a6)

* test(proxy): check the s3 refusal through the real request setup

(cherry picked from commit 03624164af4ba7dc35112041a201775436ddd4a6)

* test(proxy): exercise real setup for allowed s3 media

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 5f11068f76d77e05519fcc90a7087a2d9ef7fe95)

* fix(proxy): preserve lts allowlist contract after backport

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): preserve explicit media formats on lts

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(model-armor): fail closed on remote s3 documents

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit f9ad9f8aad6e9df611d8b4f470aeacee7ac0ff85)

* chore: bump litellm 1.108.6 -> 1.108.7

litellm 1.108.6 already shipped, so the next release off this line is 1.108.7

* feat(azure-ai): support Entra ID auth for Microsoft-Decision-1 on /v1/decisions and /v1/systemone (#46539)

Backport of #46539 to lts/1.108.x.
Cherry-picked from caad4d62045e76c1a8428ab8f316d351ca9a0a7e (main).

* refactor(azure): expose the api_base resolver and the cached Entra token provider

Prerequisite for the backport of #48529 to lts/1.108.x.
Hand-ported from the litellm/llms/azure/common_utils.py hunks of 9cf09c18fe (#46377, BaseAzureLLM.resolve_azure_api_base) and c0d88b46c9 (#47348, cached_azure_ad_token_refresh_provider) on main. The rest of those two commits is not picked.

* fix(azure): add keyless Decisions authentication (#48386) (#48529)

Backport of #48529 to lts/1.108.x.
Cherry-picked from e5757934fd7e1e37ecf566cd712ea66313315ccf (main).

* fix(files): match every spelling of a provider file id in the ownership check

enforce_provider_file_access matched the stored provider file id by exact string, and a Gemini output file
can be addressed as files/<id>, files%2F<id>, <id>/ or its full URL, all of which the Gemini file transformation
sends to the same file. Those spellings found no ownership row and fell through the no-row pass-through path.

canonical_provider_file_id collapses the spellings to the bare id; the ownership check looks up both the
spelling the caller sent and the canonical one, and store_batch_output_file_ownership stores the canonical id.

(cherry picked from commit 85e6a98866910c98d699bbbaa9b0c3af677c2719)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(files): unwrap model-encoded ids and index canonical provider ids in ownership rows

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 97c9152552a80695cedd8eb72544e2b4ddebe640)

* test(files): assert the ownership lookup outcome instead of its query shape

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 07abf10d3ef4fbd4f79ad4c69802f30d5646acb5)

* fix(files): map provider ids back to their unified file by canonical spelling

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 214e17884a61f51ffa8f307bf94e75db2bd4c834)

* chore(files): record the bound on the ownership lookup's in filter

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit d2a5f0799444c7e05295452b5efaed0e1c945318)

* fix(files): reduce any scheme or case wrapping files/<id> the way gemini does before the ownership lookup

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit e2dad6c914d337471ef9d8b6c08db72502b5f16b)

* test(files): assert the provider id lookup covers the requested ids instead of its exact list

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(files): bind the reverse lookup match with a walrus instead of a Final inside the loop

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 32dabac9f8537bc431fb99ef95a11f79a64f8370)

* fix(files): keep non-Gemini storage URLs opaque so an upload name cannot index another key's provider id

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit c9c9d1024816573500b2fda53d4f025e3ad8adaa)

* test(files): judge the provider id resolver by the mapping it returns only

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit b145f34c0b1bed76607aa7c7d6614bcd870b3f22)

* fix(mcp): treat the mcp_all scope as a wildcard any grant covers (#51578)

Datadog answers a request for mcp_all with its granular scopes, so the connect
check never found mcp_all and users looped back to Connect. Reconnecting also
re-asked every granular scope from the old grant, which overflowed the sign-in
cookie. Any non-empty grant now covers mcp_all, and a request for mcp_all does
not re-as…
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