Repository navigation
chore(sync): merge upstream v1.99.4 into h2o-main - #40
Merged
Merged
Conversation
A chunk carrying usage is stored as a pre-restamp copy, so an alias-restamped stream reaches disconnect billing with its first chunk still on the deployment model and every later chunk on the client's name. That is the same shape Azure Model Router produces, and the previous guard read it as a routed model and left the alias on the row, which is the unpriced name this PR set out to stop. Compare the assembled model against the name the proxy stamps chunks with, so the alias goes back to the deployment's model and the routed model stays.
…rough_e2e_pins test(e2e): pin openai_passthrough routing, cost logging, and file list isolation
chore(ci): promote internal staging to main
Pre-call processing rewrites request_data["model"] for aliasing and routing, so matching either key let a routed model count as the client's own name and put the wrapper model back on an Azure Model Router row.
…ting a placeholder (BerriAI#37686) SCIM group members were matched against litellm user ids only. An identity provider that lists people by email or by the OIDC subject therefore matched nothing, and the member fell through to placeholder creation. Since BerriAI#37688 made a failed member creation fail the group sync rather than drop the member, that fallthrough is no longer quiet: the placeholder is created with user_email set to the member value, the duplicate-email check rejects it, and the whole group push answers 500. So on current staging a group listing anyone by their email fails outright, every other member in the payload included. An unmatched member id is now looked up across sso_user_id and user_email in one query. Searching either field first would hide a value that names one account by its SSO identity and another by its email, and hand the group to whichever was searched first. The two are not compared alike: an email is matched the way new_user matches one before accepting a new account, case-insensitively, because matching more strictly than the layer that would reject the placeholder is what turned an id whose casing differed from the stored email into that same 500. An SSO identity is matched exactly, since OIDC defines sub as case-sensitive and nothing folds its case on the way in. An exact user_id hit is checked the same way rather than trusted outright, since a value can be one account's id and another's SSO identity or email. That is not a corner case: the placeholders this bug provisioned are keyed by the very id the provider keeps pushing, so on a tenant that already has them the placeholder wins the id lookup and the real account can never be matched. Refusing names the problem instead of silently landing on the placeholder again. Those rows still have to be deleted before the real account resolves; making the sync heal itself needs a trustworthy way to tell a placeholder from an account someone created, and created_via lives in caller-writable metadata, so it is left to a follow-up. A value that names more than one account is refused with a 400 naming the id rather than attributed to one of them. Removals resolve too, since the roster holds canonical user ids and a directory removes people by the id it added them with. A removal counts the members one value names: the id as written when the roster holds it verbatim, which is how an earlier release recorded a member it could not match, together with the members it resolves to. Counting only the accounts on the roster keeps someone removable after a second account takes their email, which resolving table-wide would not, and counting both ways of naming a member together stops one value revoking two people when it is one member's canonical id and another's email. A value naming two of the group's own members is undecidable and fails rather than guessing or reporting a removal it did not perform. Resolves LIT-5383 Co-authored-by: Yassin Kortam <yassin@berri.ai>
…ream_cost_cache_tokens fix(cost): match streamed Messages usage cost to the recorded spend
…ons (BerriAI#37748) * test: enforce PT012 so a pytest.raises block cannot hide dead assertions `with pytest.raises(...)` stops at the first statement that raises. Anything sequenced after it inside the block never runs, so an assertion written there is never checked and the test still reports green. Two sites were doing exactly that, and both assertions turned out to be wrong once they started running. tests/llm_translation/test_prompt_factory.py asserted the bedrock rejection names "requires at least one non-system message", which holds. tests/proxy_unit_tests/test_proxy_server.py asserted the prisma startup failure mentions "httpx.ConnectError", which never appears: the failure is an httpx.ConnectError whose message is "All connection attempts failed", so that test now asserts the type. Its DATABASE_URL override moves to monkeypatch, since the old restore sat below the assertion and leaked the invalid URL into every later DB test the moment the assertion started being able to fail. The remaining 72 sites are rewritten without changing what they exercise: setup that cannot raise moves above the block, a nested `patch` moves outside it, and bodies with real control flow (a stream drain, an if/else on sync_mode, a retry loop) move into a local closure the block calls. Fixing PT012 unmasked two B017s, since ruff only reports a blind pytest.raises(Exception) once the block holds a single statement. tests/proxy_unit_tests/test_auth_checks.py narrows to the ProxyException can_key_call_model actually raises. tests/local_testing/test_completion_cost.py was asserting vertex_ai/medlm-medium has no cost entry, which stopped being true at some point; that dead first half is gone and the rest of the test, which checks medlm pricing resolves above zero, now runs instead of being skipped. * chore(ci): ratchet TQ004 to 768 after the prisma test moved to monkeypatch
…ning The cost map shipped cognition/swe-1.7 at $2.50 in / $12.50 out per million with $1.00 cache reads. Those are the Lightning numbers. Cognition's own model list at https://docs.devin.ai/desktop/models has uid swe-1-7 at $0.50 / $2.50 with $0.20 cache reads, and uid swe-1-7-lightning at $2.50 / $12.50 with $1.00 cache reads, so every swe-1.7 call has been costed at 5x since the entry landed. swe-1.7 now carries the standard rates and the Lightning tier gets its own entry, in both cost map copies. The source field on both moves to the desktop models page, which is the one that lists both tiers.
`members_with_roles` is a denormalized JSON snapshot written at add-time. `_update_team_members_list` backfilled `user_id` from `user_email` but never the reverse, so a member added by `user_id` alone was stored with `user_email=None` permanently - and `/team/info` returns that blob verbatim with no join to `LiteLLM_UserTable`, so the Admin UI's member table renders "-" for a user that plainly has an email. Fix both ends: - write path: `_resolve_member_identity` resolves identity both ways off the user rows the add just touched, so new roster entries stop being born blank. - read path: `/team/info` fills blank emails from `LiteLLM_UserTable` in one indexed `user_id IN (...)` query, repairing rows already in the database. Members that already carry an email are passed through untouched and cost no query, so this only ever turns a null into the right value.
Add sync and async regression tests for the BaseLLMHTTPHandler streaming path, which forwards provider response headers for the ~30 providers that ride the generic handler and had no coverage. Also drop redundant setup prose from the moonshot invoke test docstring.
…eam_spend_rows fix(streaming): price partial-stream spend rows at the real model and keep prompt and cache fields
…itellm_forward_bedrock_response_headers
…sponse_headers Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…_keyed_pricing fix(fal_ai): price gpt-image-2 per size and quality from request params
…_model_name sagemaker_chat never put X-Amzn-SageMaker-Inference-Component on the request, so any endpoint backed by inference components answered 400 INFERENCE_COMPONENT_NAME_MISSING and the call never reached the container. The legacy sagemaker provider has built that header from model_id since BerriAI#8889, and this brings the chat provider in line. It goes on in validate_environment, which runs before the request is SigV4-signed, so the signature covers it The request body also always named the endpoint rather than the served model, which containers that validate the body's model answer with a 404. hf_model_name now becomes the body's model when it is set, and endpoints that do not set it keep sending exactly what they send today
…arametrize cases (BerriAI#37769) `pytest.raises(Exception)` with no `match=` passes on any error that broad. A TypeError from a refactor, a botched fixture, an import that moved: all of them read as the rejection the test claims to police, so the test goes green for the wrong reason and stays green after the behaviour it guards is gone. PT011 closes that gap for the 317 sites B017 could not reach, because B017 only fires on a single-statement body with no `as e` binding. Each pattern here is the message the code actually raised, recorded by running the sites under a plugin that logged the concrete type and text per call site, so the assertions describe observed behaviour rather than a guess. Where a site raises more than one message across its parametrize cases, the pattern is an alternation of what was seen; where the exception carries an empty `str()` and puts the text on `.message`, the site keeps a narrow `noqa` with the reason. PT014 removes four parametrize cases that were listed twice. The duplicate re-runs an assertion that already passed, and it usually marks a case someone meant to vary and forgot to edit.
…r_email fix: populate team member emails missing from the roster snapshot
…_response_headers fix(bedrock): forward provider response headers on chat completions
…we_1_7_pricing fix(cognition): price swe-1.7 at the standard tier, add swe-1.7-lightning
…inference_component_header fix(sagemaker_chat): send the inference component header and honor hf_model_name
Keeps the spend-log key redaction helper and its tests on top of the moved base.
The spend-log helper no longer treats a 64-hex shape as proof a value was already hashed, so this case has to say where the hash came from. Reconciles the test that came in with BerriAI#31799 against that change.
The hashed-jwt branch trusted the value's shape alone, so a caller-supplied key in that shape was stored unhashed. Both pass-throughs now require the value to match the auth-time user_api_key_hash, and the shape check is a full match.
The proxy conftest already snapshots master_key and prisma_client around every test, because a value left behind on litellm.proxy.proxy_server poisons the rest of the xdist worker. llm_router has the same problem. The PTU rollup reads the running router out of sys.modules, so a router a sibling test left behind lands in its deployment scan and three test_ptu_flat_cost_rollup tests fail or pass depending on how xdist happens to split the shard.
Master-key auth stamps the stable alias litellm_proxy_master_key instead of the raw key, so spend logs carry a readable, non-secret identifier for those rows. The new redaction path only recognized sha256 and hashed-jwt shapes, so it hashed that alias and broke continuity with every master-key row written before this change. The alias joins the recognized non-secret values, still behind the same provenance gate, so a caller who sends the alias string as their own bearer token still gets it hashed.
…log_persistence fix(spend-tracking): hash raw api keys before persisting to spend logs
…itellm_scx_ai_provider Resolves the three conflicts against the JSON provider registry refactor. The hardcoded api.scx.ai base-url branch in get_llm_provider_logic.py is dropped in favour of the generic JSONProviderRegistry.get_by_base_url lookup, which reads the same base_url and api_key_env from providers.json and additionally honours an explicitly passed api_key. constants.py and types/utils.py keep both the cognition and scx-ai entries added on either side.
Applies the review suggestions. The cost map now carries the rates published on https://scx.ai/pricing, GLM-5.2 at 0.61 in, 0.22 cached, 1.98 out and Qwen3.8-Max at 1.65 in, 0.21 cached, 4.99 out per million tokens, and cites that page as the source rather than a third party gateway. The provider link is corrected to https://docs.litellm.ai/docs/providers/scx_ai to match the page that shipped as scx_ai.md. Both the primary files and their backup mirrors are updated.
…ck runtime
GPT-5.6 Sol, Terra and Luna reached the bedrock-runtime data plane on
2026-08-17, separately from the existing bedrock-mantle path. On runtime
they are served only through cross-region inference profiles, so
bedrock/us.openai.gpt-5.6-* had no cost map entry and fell through to the
Invoke route, which rewrites the token cap to max_tokens and is rejected
as unsupported_parameter on both /v1/chat/completions and /v1/responses.
Register the Geo and Global profiles as bedrock_converse so routing
reaches Converse, which AWS documents and serves for these models, and
price each profile from its own published rate table. No bare key: the
control plane reports inferenceTypesSupported INFERENCE_PROFILE with no
on-demand throughput, so a bare id is not invocable.
Declare the published cache-read and cache-write rates. Bedrock rejects
an explicit cachePoint block for these models, so supports_prompt_caching
stays off, but it caches long prefixes implicitly and reports the cache
tokens in usage either way. Without the cost fields a cache-read turn
bills only its uncached tokens: measured against live Bedrock, a
15609-token cached prefix came to $0.000176 instead of $0.00876095.
Clients that resend a long prefix every turn are the worst affected.
Reasoning stays unadvertised. Converse rejects the Anthropic-shaped
thinking block LiteLLM sends for reasoning_effort; the shape these models
accept is additionalModelRequestFields {"reasoning": {"effort": ...}},
which needs a transform change tracked by BerriAI#34105. Advertising it without
that change is what made the earlier attempt in BerriAI#37307 fail.
…_41230_0915 chore(release): backport BerriAI#41230 to stable/1.99.x and cut 1.99.2
…tive /v1/messages Backport of BerriAI#42152 to stable/1.99.x. Cherry-picked from merge commit e912ebe (litellm_claude_code_safeguards_passthrough).
… beta to Bedrock Invoke and Vertex on /v1/messages Backport of BerriAI#42288 to stable/1.99.x. Cherry-picked from merge commit fc82f6e (litellm_safeguards_bedrock_vertex_messages). The line has no bedrock_mantle beta-header mapping and no Mantle /v1/messages route, so the Mantle mapping, its test file, and the bedrock_mantle test parameter are left out.
Hand-ported to stable/1.99.x from 47b2479 on main (fix(bedrock): gate Invoke tool search on the model map's supports_tool_search flag), the one prerequisite the BerriAI#42288 handler tests need; the rest of that commit stays on main.
…ine's budgets The picked TypedDict fields use read-only Sequence[Mapping[str, object]] annotations and the picked Vertex test carries a test-quality-ok marker, so stable/1.99.x's LIT001, LIT012 and TQ008 budgets hold. Static typing only, no runtime change.
Backport of BerriAI#42048 to stable/1.99.x. Cherry-picked from 7966f50 (main). The safeguards backport maps the dangerous-tool-use-2026-09-03 beta for Bedrock, which Claude Opus 4.5 on Bedrock Invoke rejects as an invalid beta flag, so the all-beta-headers Bedrock cases run on Claude Fable 5.1 as they do on main.
…guards_1_99_x fix(anthropic): backport BerriAI#42152 and BerriAI#42288 to stable/1.99.x for v1.99.2
…acking Backport of BerriAI#41607 to stable/1.99.x. Cherry-picked from deb9d8a (main). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
feat(typesafe): backport BerriAI#41607 to stable/1.99.x for v1.99.2
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>
chore(release): bump stable/1.99.x to 1.99.3
…e configs (BerriAI#39631) Adapted for stable/1.99.x: The Responses parametrize cases target a test class this line does not have, so the two gpt-6-astra cases are kept as a standalone test in the same file. (cherry picked from commit 025a3ca)
…et (BerriAI#39726) Adapted for stable/1.99.x: this line predates budget rollover (BerriAI#38514), so each end user's spend counter is zeroed through the existing counter_keys list instead of counter_resets, and its cache entry is evicted via end_user_cache_key. Signed-off-by: amasen02 <amasen02@users.noreply.github.com> (cherry picked from commit daced81)
…BerriAI#40639) Adapted for stable/1.99.x: this line predates budget rollover (BerriAI#38514), so the fix is applied to _commit_budget_cascade_once directly. End users reset on the budget link plus a NULL budget_id branch for the default tier, which is what upstream's _queue_enduser_resets does with rollover off. The rollover test hunk is dropped. (cherry picked from commit 8a4fae0)
…_gpt6_budget_0924 chore(release): backport BerriAI#39631, BerriAI#39729, BerriAI#40639 to stable/1.99.x and cut 1.99.4
Brings h2o-main (upstream 1.93.0 release line + the h2o commits) up to the upstream v1.99.4 release. The 1.93.0 release-line backports on our side (BerriAI#33499, BerriAI#33847, BerriAI#33869, BerriAI#33904) are all present in v1.99.4 from main, so every file only they touched takes upstream's version; the h2o changes are re-applied on top of upstream's new code. Conflicted files and their resolution: - Dockerfile, docker/Dockerfile.database, docker/Dockerfile.non_root: upstream (the /opt/prisma bake from the 1.93 backports is in v1.99.4; no h2o lines). - litellm-rust/Cargo.lock, litellm-rust/crates/python-bridge/src/lib.rs: upstream (release-line backport only). - pyproject.toml, uv.lock: upstream. No h2o commit added a dependency. - litellm/litellm_core_utils/core_helpers.py, get_litellm_params.py, litellm/llms/anthropic/experimental_pass_through/messages/transformation.py, litellm/main.py, litellm/proxy/utils.py, litellm/router.py, litellm/types/guardrails.py, litellm/proxy/guardrails/guardrail_hooks/ model_armor/{__init__,file_scanning,model_armor}.py: upstream (release-line backports, e.g. coerce_token_limit / skip_unscannable_attachments, already in v1.99.4). - tests/test_litellm/proxy/guardrails/guardrail_hooks/test_model_armor.py, tests/test_litellm/proxy/test_proxy_utils.py, tests/test_litellm/test_main.py, tests/test_litellm/test_router.py: upstream (same backports). - litellm/litellm_core_utils/get_llm_provider_logic.py: upstream code, h2o redaction kept -- "dynamic_api_key needs to be a string." never echoes the key. - litellm/proxy/auth/user_api_key_auth.py: upstream's %-style logging, h2o redaction kept -- the custom-header debug line no longer logs the (abbreviated) key. - litellm/proxy/route_llm_request.py: upstream. The h2o lazy DB reload (reload_models_on_demand) is DROPPED: v1.99.4's route_request retries a ProxyModelNotFoundError through model_registry_read_through, which loads the missing model from the DB (bounded by a miss TTL and a resync budget). Upstream's read-through requires store_model_in_db=True. - litellm/llms/bedrock/chat/converse_transformation.py: upstream's fix for the same bug as h2o #24 (the toolChoice / tool_choice.type conflict and the missing type): native toolConfig.toolChoice keeps the caller's choice and the passthrough drops its type. h2o's rework that deleted the native toolChoice is dropped in its favour. Re-applied on top: the guards upstream lacks -- no passthrough without MAPPED tools, for tool_choice="none", or for a non-bool parallel_tool_calls (_drop_parallel_tool_use_config_with_nothing_to_say). - tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py: both sides kept; the h2o tests re-pinned to upstream's design (native toolChoice carries the choice, passthrough carries only disable_parallel_tool_use); the test of the removed h2o builder is dropped. Also, outside the conflicts: - litellm/llms/gemini/count_tokens/handler.py: upstream; its own "if not contents" guard supersedes the h2o None check. - litellm/llms/vertex_ai/vertex_llm_base.py: h2o base64 credentials kept, ruff-formatted. - litellm/integrations/h2o/router/h2orouter_policy.py: docstring no longer names the removed reload_models_on_demand. - gateway/routes/allowlist.py: the h2o /v1/router/models endpoint added to the gateway component (v1.99.4 splits routes across gateway/backend and test_component_allowlists fails on an uncovered route). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… refuse
Claude Opus 5.5 (and Fable 5.1) think on every request and refuse a forced tool --
`400 tool_choice: type "tool" and "any" are not supported for this model`. Measured in h2oGPTe CI
(2026-09-29): 81 such refusals in one smoke run, every JSON-mode sub-call (query rewrite,
classification) returning `{}` after two retries.
v1.99.4 already chooses native structured output by the model map's
`supports_native_structured_output` (upstream BerriAI#33235) and already maps claude-opus-5,
claude-mythos-5, claude-sonnet-5, claude-fable-5 and claude-haiku-4-5(-20251001) with it. Ported on
top from upstream's later Opus 5.5 work (as reviewed on h2o/claude-structured-output-no-forced-tool):
* model map (both copies): the upstream-main entries for claude-opus-5-5 and claude-fable-5-1,
which v1.99.4 lacks -- prices unchanged from upstream, without the fields v1.99.4's code and
schema do not know (the *_batches cache costs, supports_anthropic_compaction,
supports_fast_mode). `supports_forced_tool_use: false` on both, as upstream.
* `AnthropicModelInfo.forced_tool_use_unsupported`: an explicit `supports_forced_tool_use: false`.
JSON mode on such a model offers the JSON tool without forcing it.
* `_apply_forced_tool_choice`: a caller's own forced tool_choice on such a model is downgraded to
`auto` under drop_params (with a warning), and otherwise refused client-side with a 400 that says
how -- as upstream does.
Tests: tests/test_litellm/llms/anthropic/chat/test_claude_json_mode_never_forces_a_tool_it_refuses.py
(native output for the eight newer models, the guard alone, the unchanged legacy path, the caller
downgrade and refusal); the model-map schema gains `supports_forced_tool_use` (test_utils.py and
the committed model_prices_and_context_window.schema.json, regenerated with
ci_cd/generate_model_prices_schema.py); test_fallback_generalizations uses claude-fable-6-1 as its
unmapped Fable id now that claude-fable-5-1 is mapped, as upstream main does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Brings
h2o-mainup to upstream v1.99.4, and fixes JSON mode on the newer Claude models on top.This pairs with #39, which moves
mainto v1.99.4. Merge #39 first. Once both are in, #3 shows only the h2o delta against v1.99.4.Commits
tool_choice. The fix ports upstream's model-map entries for both models, withsupports_forced_tool_use: false. On those models the JSON tool is offered rather than forced, and a caller's own forced tool choice is downgraded toautounderdrop_paramsor refused with a clear 400. This supersedes fix(anthropic): JSON mode never forces a tool the newer Claude models refuse #38.Worth a reviewer's attention
store_model_in_db: true, so nothing that worked before is lost./v1/router/modelsendpoint is listed for the gateway component.Known follow-up
The h2o integration files fail about 365 of upstream's graduated lint rules. The fork's CI does not run that lint job, so this does not block the merge.
Testing
New test file
tests/test_litellm/llms/anthropic/chat/test_claude_json_mode_never_forces_a_tool_it_refuses.py. The model-map schema was regenerated withci_cd/generate_model_prices_schema.py. The fork's unit-test workflow runs on this PR.🤖 Generated with Claude Code