Skip to content

test(integration): cover anthropic_messages endpoint contracts - #44704

Merged
mateo-berri merged 11 commits into
mainfrom
litellm_endpoint_contracts_anthropic_messages
Oct 14, 2026
Merged

mateo-berri merged 11 commits into
mainfrom
litellm_endpoint_contracts_anthropic_messages

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Anthropic /v1/messages contracts had no real-proxy wire tests
  • Claude Code gateway alias and OAuth device flow had zero integration tests
  • Vertex and Azure AI Claude branches, count_tokens, Skills uploads and error envelopes were unasserted on the wire

How it solves it:

  • Adds deterministic integration tests that drive the real proxy with real client spellings
  • Each test asserts the exact upstream request and the parsed client response
  • Every test was proven by a one-line mutation under litellm/
  • Six current-main product bugs are pinned as BUG skips with full test bodies

What is now covered

A native Anthropic deployment now has wire tests for the Claude Code CLI spelling (POST /v1/messages?beta=true with the full comma-separated anthropic-beta list including a made-up future beta, safeguards, metadata.user_id, tools and system cache_control), stream false and true, asserting the forwarded anthropic-beta carries exactly the client's tokens (none dropped, none added), the whole upstream JSON body and safeguard_results reaching the client unchanged. Upstream 429 and 400 errors are asserted as Anthropic error envelopes with the right status and SDK exception class, an upstream 529 is compared as a whole envelope, a mid-stream upstream error is asserted as the client's full SSE sequence (message_start then error, no message_stop), an upstream stream that closes after message_start and a text delta without message_stop is asserted to end with the incomplete-stream error event instead of a clean 200 (a BUG skip, main relays it as a clean 200), and image (base64 and url), PDF document, tool_result with is_error and nested content, and repeated tool-use history are asserted byte-equal at the upstream with every returned block type parsed by the Anthropic SDK

The Claude Code gateway aliases /claude_code_gateway/v1/messages and /claude_code_gateway/v1/messages/count_tokens are asserted to 404 with the exact {"detail": "Claude Code gateway is not enabled"} body without reaching the provider when the gateway is disabled, and on an owned proxy with the gateway enabled to produce the identical upstream request (method, path, x-api-key swap, anthropic-beta, full body) and identical client response or SSE as /v1/messages for stream false and true, to refuse a model outside the key allowlist with the same 403 envelope as /v1/messages without reaching upstream, and to write a spend row attributed to the calling key. The count_tokens alias is asserted to reach /v1/messages/count_tokens with x-api-key, the exact body and the same {input_tokens} as the native route, and to refuse a model outside the key

The gateway OAuth device flow is driven end to end against a scripted generic SSO identity provider: authorization_pending before SSO and again after SSO but before user-code verification, a wrong verification code rejected with 400 Invalid verification code while the poll stays authorization_pending, expired_token for a device code whose poll secret is wrong, exactly one access token on success, expired_token on replay, unsupported_grant_type and invalid_grant for other grants, and the issued bearer working on the gateway, stream false and true with ?beta=true, only for models both the user and the team allow (user [A, B], team [A, C]: A passes, B gets 403 team_model_access_denied, C gets through on the team grant), with each success writing a spend row for the signed-in user and team

A vertex_ai/claude-* deployment is asserted to call :rawPredict or :streamRawPredict?alt=sse with Bearer auth, anthropic_version: vertex-2023-10-16, no model field and only supported betas. An azure_ai/claude-* deployment is asserted to call /anthropic/v1/messages with x-api-key and no Authorization or api-key leak, with and without an /anthropic api_base suffix, and, for stream false and true, a body carrying output_config.format and a compact_20260112 context-management edit is asserted to reach Azure verbatim with exactly anthropic-beta: structured-outputs-2025-11-13, so the auto-injected compact-2026-01-12 (null for azure_ai in litellm/anthropic_beta_headers_config.json) is proven filtered. Native /v1/messages/count_tokens is asserted through both client.messages.count_tokens and client.beta.messages.count_tokens (the ?beta=true spelling) to forward messages, system and tools with x-api-key and anthropic-version, return {input_tokens} unchanged, refuse a key without model access before upstream, and fall back to the local count when the provider errors, with the fallback pinned to the constant 65 instead of read from /utils/token_counter

POST /v1/skills?beta=true with the documented repeated files[] field is asserted to reach the provider as one text part and two file parts with the exact names, filenames and bytes, and the client parses the returned Skill

Gap Test node Mutation (one line under litellm/) Assertion tripped
anthropic_messages-1 (1A) tests/integration/messages_endpoint/providers/anthropic/test_anthropic_wire.py::test_anthropic_messages_preserves_cli_beta_safeguards_and_result[non_stream], [stream] litellm/llms/anthropic/pass_through/messages/transformation.py should_filter_anthropic_beta_headers return self._resolved_provider != "anthropic" -> return True test_anthropic_wire.py:283 assert sorted(request.headers["anthropic-beta"].split(",")) == sorted(beta.split(",")) got ['context-management-2025-06-27', 'interleaved-thinking-2025-05-14', 'prompt-caching-scope-2026-01-05'] (Claude Code, made-up future and token-count betas stripped)
anthropic_messages-1/2 (gateway beta) ...test_anthropic_gateway_wire.py::test_enabled_gateway_matches_native_messages_route[non_stream], [stream], ::test_enabled_gateway_attributes_spend_to_virtual_key same return True mutation test_anthropic_gateway_wire.py:152 and :316 assert sorted(request.headers["anthropic-beta"].split(",")) == client_betas got the same three betas
anthropic_messages-1 (1T, allowlist drift) same node, both cells litellm/types/llms/anthropic.py:430 delete safeguards: ReadOnly[list[dict[str, object]] | None] from AnthropicMessagesRequestOptionalParams (the allowlist get_requested_anthropic_messages_optional_param reads through _anthropic_messages_optional_param_keys) test_anthropic_wire.py:297 upstream whole-body assertion, safeguards missing from the forwarded body
anthropic_messages-2 tests/integration/messages_endpoint/providers/anthropic/test_anthropic_gateway_wire.py::test_shared_gateway_route_is_disabled_without_reaching_provider[messages] gateway_endpoints.py /v1/messages alias dependencies=_GATEWAY_ENABLED, -> dependencies=(), test_anthropic_gateway_wire.py:97 assert response.status_code == 404 got 500, and the upstream handler saw /v1/messages
anthropic_messages-2 ...test_anthropic_gateway_wire.py::test_shared_gateway_route_is_disabled_without_reaching_provider[count_tokens] gateway_endpoints.py /v1/messages/count_tokens alias dependencies=_GATEWAY_ENABLED, -> dependencies=(), test_anthropic_gateway_wire.py:97 assert response.status_code == 404 got 200 {"input_tokens":9}
anthropic_messages-2 ...test_anthropic_gateway_wire.py::test_enabled_gateway_count_tokens_alias_matches_native_count_tokens_route gateway_endpoints.py count_tokens alias handler count_tokens, -> anthropic_response, test_anthropic_gateway_wire.py:249 assert gateway_response.status_code == 200 got 400
anthropic_messages-2 same node endpoints.py count_tokens drop tools=data.get("tools"), upstream handler assert _JSON_OBJECT.validate_json(request.body) == expected_provider_body and line 250 got 23 instead of 41
anthropic_messages-2 ...test_anthropic_gateway_wire.py::test_enabled_gateway_matches_native_messages_route[non_stream], [stream] (unchanged) gateway_endpoints.py alias handler anthropic_response to count_tokens upstream request.target == "/v1/messages" and typed Message validation
anthropic_messages-2 ...test_anthropic_gateway_wire.py::test_enabled_gateway_refuses_model_outside_virtual_key (unchanged) auth_checks if _check_model_access_helper( to if True or _check_model_access_helper( upstream handler raised, restricted model reached /v1/messages
anthropic_messages-2 ...test_anthropic_gateway_wire.py::test_enabled_gateway_attributes_spend_to_virtual_key (unchanged) spend_tracking_utils.py api_key=str(api_key) to api_key="" assert spend_rows == (...) got ([], [])
anthropic_messages-3 tests/integration/authorization/test_claude_code_gateway_oauth.py::test_device_authorization_polls_complete_sso_and_mints_a_model_restricted_bearer gateway_endpoints.py if not _verify_cli_sso_poll_secret(flow, poll_secret): -> if not True: test_claude_code_gateway_oauth.py:231 assert ... wrong_secret ... == {"error": "expired_token"} got authorization_pending
anthropic_messages-3 same node gateway_endpoints.py sso_complete / user_code_verified guard or -> and test_claude_code_gateway_oauth.py:270 assert still_pending.status_code == 400 got an access_token
anthropic_messages-3 (M6R1) same node ui_sso.py if not isinstance(expected_user_code_hash, str) or not secrets.compare_digest( -> if isinstance(expected_user_code_hash, bool) and not secrets.compare_digest( test_claude_code_gateway_oauth.py:279 assert wrong_code_completion.status_code == 400 got 200
anthropic_messages-3 (team grant) same node user_api_key_auth.py "models": () if team_object is not None else user_models(user_object), -> "models": user_models(user_object), test_claude_code_gateway_oauth.py:422 assert model_c_response.status_code == 200 got 403 key_model_access_denied
anthropic_messages-3 (concurrent claim) same node gateway_endpoints.py _claim_device_code return claims == 1 -> return claims >= 1 assert len(successful_polls) == 1 got 7 successful polls, red 3 of 3 runs
anthropic_messages-5 (model refusal) ...test_anthropic_count_tokens_wire.py::test_anthropic_count_tokens_forwards_body_and_refuses_a_key_without_model_access[messages_count_tokens], [beta_messages_count_tokens] model access check if model is not None: -> if model is not None and route != "/v1/messages/count_tokens": pytest.raises(anthropic.PermissionDeniedError) reports DID NOT RAISE in both cells
anthropic_messages-4 tests/integration/providers/test_vertex_partner_messages_wire.py::test_vertex_partner_messages_uses_raw_predict_contract_and_typed_response[non_stream], [stream] (unchanged) delete anthropic_messages_request["anthropic_version"] = "vertex-2023-10-16" whole-body assert ... request.body == expected_body
anthropic_messages-5 tests/integration/messages_endpoint/providers/anthropic/test_anthropic_count_tokens_wire.py::test_anthropic_count_tokens_forwards_body_and_refuses_a_key_without_model_access[messages_count_tokens], [beta_messages_count_tokens] endpoints.py count_tokens drop tools=data.get("tools"), upstream handler whole-body assertion, and test_anthropic_count_tokens_wire.py:108 assert result.model_dump() == {"input_tokens": _COUNTED_INPUT_TOKENS} got 23
anthropic_messages-5 (upstream error relay) ...test_anthropic_count_tokens_wire.py::test_anthropic_count_tokens_relays_an_upstream_server_error, ::test_anthropic_count_tokens_relays_an_upstream_client_error proxy_server.py _try_provider_token_count replace the raise ProxyException(...) on a provider error with return None (the local fallback that #46121 removed) pytest.raises(anthropic.InternalServerError) and pytest.raises(anthropic.BadRequestError) report DID NOT RAISE
anthropic_messages-3 (refresh token) test_claude_code_gateway_oauth.py::test_device_authorization_polls_complete_sso_and_mints_a_model_restricted_bearer drop refresh_token from proxy_credential_response _AccessToken.model_validate_json fails with refresh_token Field required
anthropic_messages-6 ...test_anthropic_wire.py::test_anthropic_messages_preserves_upstream_error_status_and_body[rate_limit], [invalid_request] (unchanged) _anthropic_error_json_response drop **envelope, whole-body assert caught.value.response.json() == {...}
anthropic_messages-6 ...test_anthropic_wire.py::test_anthropic_messages_stream_surfaces_upstream_error_event streaming_model_restamp.py restamped_text.encode("utf-8") if index == decider else frame ... -> b"" if index == decider else frame ... (drops message_start) test_anthropic_wire.py:577 assert cc.sse_events(response.text) == (("message_start", ...), ("error", error)) got only the error event
anthropic_messages-7 ...test_anthropic_wire.py::test_anthropic_messages_preserves_image_document_and_tool_result_blocks (unchanged) native messages transform drops document blocks after strip_advisor_blocks_from_messages whole-body upstream assertion on messages
anthropic_messages-8 tests/integration/providers/test_azure_ai_claude_messages_wire.py::test_azure_ai_claude_messages_preserves_target_auth_beta_and_typed_response[*] (4 cases, unchanged) litellm/llms/azure_ai/anthropic/messages_transformation.py omit api_base + "/v1/messages" assert request.target == api_path
anthropic_messages-8 (8R2, new) ...test_azure_ai_claude_messages_wire.py::test_azure_ai_claude_messages_filters_auto_injected_betas_by_azure_support[non_stream], [stream] litellm/llms/anthropic/pass_through/messages/transformation.py:106 return self._resolved_provider != "anthropic" -> return False test_azure_ai_claude_messages_wire.py:185 assert request.headers.get("anthropic-beta") == expected_beta got compact-2026-01-12,structured-outputs-2025-11-13
skills tests/integration/providers/test_anthropic_skills_create_wire.py::test_anthropic_skill_create_forwards_repeated_files_as_file_parts http_parsing_utils.py parsed_form_data.setdefault(clean_key, []).append(value) -> parsed_form_data[clean_key] = [value] upstream handler assert tuple(_part_summary(part) ...) == (("display_title", ...), ("files[]", "synthetic-skill/SKILL.md", ...), ("files[]", "synthetic-skill/helper.py", ...)) saw one file part, and line 67 got 500

Every mutation path above is the real path at this tip (litellm/llms/anthropic/experimental_pass_through/ no longer exists, the native config lives in litellm/llms/anthropic/pass_through/messages/transformation.py). Mutations on disjoint test nodes were applied together in one proxy restart (three restarts, then the stream mutation and the two OAuth poll mutations each on their own restart), each node went red on the named assertion, everything was reverted (git status litellm/ clean) and both group runs below are the green reruns

Answers to the reviewer at 12e4a48, with evidence from this rig:

  • M6R2 (_mint_access_token team_models=[]) is an equivalent mutant. The test stayed green under it because _refresh_session_token_grants in user_api_key_auth.py re-reads the team's models from Postgres on every session-token request, so the minted claim is never the source of truth. The team grant is now asserted (user [A, B], team [A, C]) and the refresh line itself is the mutation that kills it
  • M8R (client beta dropped in the count_tokens transformation) cannot be killed today: the client's anthropic-beta never reaches that transformation on main, so the provider receives only token-counting-2024-11-01. The merged-header contract is pinned as a BUG skip below for both SDK spellings
  • M1R stays an equivalent mutant: get_supported_anthropic_messages_params has no request-path caller on native /v1/messages

Answers to the reviewer at ab52731, with evidence from this rig at 6e71084 (origin/main merged in):

  • 8R2 survived because Azure never receives client betas (the BUG skip below). The new test_azure_ai_claude_messages_filters_auto_injected_betas_by_azure_support drives betas LiteLLM injects from the body, which do reach the filter, and 8R2 now turns both cells red with compact-2026-01-12 leaking. The older Azure test no longer claims beta filtering
  • 1R is equivalent because get_supported_anthropic_messages_params is dead on this route. The allowlist that actually drops unknown top-level fields is AnthropicMessagesRequestOptionalParams, and deleting safeguards there (1T) turns both safeguards cells red on the whole-body assertion, so the allowlist-drift claim of gap 1 is now proven
  • The mutation records cite litellm/llms/anthropic/pass_through/messages/transformation.py, the real path at this tip
  • The five BUG skips are real product bugs on merged main (each re-run with its skip removed at 6e71084, wrong values below). This workflow forbids product code under litellm/, so they are not fixed here and the halves they pin are recorded as partial, not covered, in the table that follows

Answers to the reviewer at 6e71084, with evidence from this rig at 52a85d5:

  • The five existing BUG skips were re-run with the skip line removed at 6e71084 and each is still red on the claimed assertion: retry-after None == '7', 529 reaches the client as HTTP 500 api_error, count_tokens returns 65 instead of 73 with thinking, tool_choice and output_config missing from the provider body, count_tokens sends only token-counting-2024-11-01 for both SDK spellings, and Azure gets no anthropic-beta. They are real bugs in product code this tests-only PR may not change, so those halves stay partial and are listed as dropped below rather than claimed covered
  • The sorted(set(...)) expectation is gone at all three sites. Each now compares the upstream header token-for-token with the header the client sent (beta.split(",") and cc.CLI_BETA.split(",")), so any dropped, added or duplicated beta fails. Order is not compared on purpose: merge_anthropic_beta_headers sorts by design and Anthropic reads the header as a set of flags, so pinning the client's order would pin a fact we do not own
  • test_anthropic_messages_stream_ending_without_message_stop_surfaces_an_error_event is new. The upstream sends message_start, content_block_start and one text_delta, then closes cleanly. With the skip removed it fails at test_anthropic_wire.py:649 (650 with the skip line) because the client gets exactly those three events and HTTP 200, no error event. BaseAnthropicMessagesStreamingIterator.async_sse_wrapper appends that event, but native /v1/messages streams through PassThroughStreamingHandler.chunk_processor, which reads message_stop only to decide prompt-cache evidence for logging and never appends that event to the client stream. A dropped-connection variant was tried and dropped: the proxy had not committed headers yet, so it answers 500 with an Anthropic envelope, which is not the truncated-200 shape and depends on timing

Answers to the reviewer at dff0cb2, with evidence from this rig at 7a536b7:

  • The six BUG skips are not claimed as coverage. The table below lists each of those halves as not covered and unproven until the product fix lands, since this tests-only PR may not change litellm/
  • Single-token issuance now fires 8 concurrent device_code polls and asserts exactly one 200 with a valid access token and 7 expired_token 400s, while the later sequential replay check stays. Mutating _claim_device_code return claims == 1 -> return claims >= 1 alone turns it red 3 of 3 runs with 7 successful polls, and it is green twice after revert
  • The named mutation "delete safeguards from the supported-params list" is an equivalent mutant because AnthropicMessagesConfig.get_supported_anthropic_messages_params has no callers. Gap 1's allowlist claim rests only on the AnthropicMessagesRequestOptionalParams TypedDict-key mutation (1T), which is killed
  • The count_tokens model refusal no longer pins the OpenAI-shaped key_model_access_denied JSON as the Anthropic contract. It asserts what an Anthropic SDK user sees, anthropic.PermissionDeniedError with status 403 and the requested model in the message, plus no upstream request. Skipping the model check for /v1/messages/count_tokens turns both spellings red with DID NOT RAISE PermissionDeniedError. The current body shape is recorded here only as a product observation
  • Merging origin/main brought fix(proxy): raise on provider count_tokens errors instead of falling back to tiktoken #46121, which relays a provider count_tokens error instead of counting locally, and feat(claude_code_gateway): issue rotating refresh tokens and a revocation endpoint #44635, which adds refresh_token, user_id and team_id to the device-code token response. The two count_tokens fallback tests now assert the relayed 500 and 400 through the Anthropic SDK, and the OAuth test asserts the full new token body and the invalid_request answer for a refresh grant with no token. M9R (tools=None in local counting) no longer applies since the error path never counts locally, so its row is dropped
  • Ruff findings are fixed (unused model_b, the placeholder-free f-string, the unused Wire import) and the changed files are ruff format clean

Coverage at this tip:

Gap Status What is still open
anthropic_messages-1 covered
anthropic_messages-2 covered
anthropic_messages-3 covered
anthropic_messages-4 covered
anthropic_messages-5 partial messages, system, tools, auth, model refusal and upstream error relay are covered. Forwarding of thinking, tool_choice, output_config and the merge of the client anthropic-beta are not covered, their tests are BUG skips and the contract stays unproven until the product fix lands
anthropic_messages-6 partial 429 and 400 envelopes and the mid-stream error frame are covered. Upstream retry-after on 429, 529 overloaded_error passthrough, and the error event for a stream closed before message_stop are not covered, their tests are BUG skips and those contracts stay unproven until the product fixes land
anthropic_messages-7 covered
anthropic_messages-8 partial URL, auth and filtering of auto-injected betas are covered. Forwarding a supported client beta to Azure is not covered, its test is a BUG skip

Product bugs on current main, each pinned with pytest.skip("BUG: ...") as the first line of a full test body:

  • test_anthropic_wire.py::test_anthropic_messages_preserves_upstream_rate_limit_retry_after: an upstream 429 with retry-after: 7 reaches the client as a 429 Anthropic envelope but with no retry-after header (test_anthropic_wire.py:464 got None)
  • test_anthropic_wire.py::test_anthropic_messages_preserves_upstream_overloaded_error: an upstream 529 overloaded_error reaches the client as HTTP 500 api_error (test_anthropic_wire.py:516 got 500)
  • test_anthropic_count_tokens_wire.py::test_anthropic_count_tokens_preserves_thinking_tool_choice_and_output_config: thinking, tool_choice and output_config never reach the provider count call, and the client gets the local count (65) instead of the provider's (73)
  • test_anthropic_count_tokens_wire.py::test_anthropic_count_tokens_merges_the_client_beta_with_the_token_counting_beta[messages_count_tokens], [beta_messages_count_tokens]: a client anthropic-beta: client-future-beta-2099-01-01 is dropped, and the provider receives only token-counting-2024-11-01 instead of client-future-beta-2099-01-01,token-counting-2024-11-01
  • test_anthropic_wire.py::test_anthropic_messages_stream_ending_without_message_stop_surfaces_an_error_event: an upstream stream that closes after message_start and a delta, with no message_stop, reaches the client as HTTP 200 with those events and no error event (test_anthropic_wire.py:649 with the skip removed)
  • test_azure_ai_claude_messages_wire.py::test_azure_ai_claude_messages_forwards_supported_beta: interleaved-thinking-2025-05-14, listed as supported for azure_ai in litellm/anthropic_beta_headers_config.json, is dropped and no anthropic-beta reaches Azure

Linear ticket

Related to LIT-6816 and LIT-7940

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Rig set up as in .circleci/scripts/run_integration.sh: Postgres circle_test, Redis, the owned scripted upstream on 127.0.0.1:8190 and the proxy on 127.0.0.1:4000

python tests/integration/run.py providers \
  tests/integration/messages_endpoint/providers/anthropic/test_anthropic_wire.py \
  tests/integration/messages_endpoint/providers/anthropic/test_anthropic_gateway_wire.py \
  tests/integration/messages_endpoint/providers/anthropic/test_anthropic_count_tokens_wire.py \
  tests/integration/providers/test_vertex_partner_messages_wire.py \
  tests/integration/providers/test_azure_ai_claude_messages_wire.py \
  tests/integration/providers/test_anthropic_skills_create_wire.py
python tests/integration/run.py management \
  tests/integration/authorization/test_claude_code_gateway_oauth.py

After (de0c18a, a merge of origin/main onto 7a536b7 that picks up the migration lock fix)

providers

  1. 30 passed, 7 skipped in 86.24s at de0c18a
  2. 30 passed, 7 skipped at 7a536b7 and twice at 744c957 before the earlier merges

management

  1. 1 passed in 87.37s at de0c18a
  2. 1 passed twice at 7a536b7

make check: check: PASS. ruff check, ruff check --config ruff-tests.toml and ruff format --check pass on the changed files

Type

Test

Caveats (if any)

Low

  • Deleting safeguards from get_supported_anthropic_messages_params is not killable
    • That list has no call site on this route, the AnthropicMessagesRequestOptionalParams mutation is killed instead
  • Six product bugs stay open on main and leave gaps 5, 6 and 8 partial
    • Fixing them needs product changes outside this tests-only PR
  • The minted-token team_models mutation is not killable
    • Session-token auth re-reads team grants from Postgres on every request
  • Main falls back to the local count on an upstream 400 too
    • The test pins this current behavior
  • The Anthropic SSE formatter mutation is unreachable on native passthrough
    • The restamp relay line was mutated instead
  • The forwarded anthropic-beta is compared as a token multiset, not in the client's order
    • LiteLLM sorts the merged header by design and the order carries no meaning upstream

Note

Low Risk
Test-only changes under tests/integration/ with no production code modifications; risk is limited to CI runtime and test maintenance.

Overview
Adds wire-based integration tests that drive the real LiteLLM proxy against scripted upstream peers and assert exact provider requests plus Anthropic SDK–parsed responses—no litellm/ product changes.

Coverage spans native /v1/messages (CLI anthropic-beta, safeguards, rich blocks, error envelopes, mid-stream SSE errors), /v1/messages/count_tokens (both SDK spellings, model access, upstream error relay), Claude Code gateway aliases (disabled 404, parity with native routes, spend attribution), a full device OAuth + generic SSO flow (poll semantics, concurrent token claim, team/user model grants), Vertex :rawPredict / :streamRawPredict, Azure AI /anthropic/v1/messages auth/path/beta filtering, and POST /v1/skills multipart files[] forwarding.

Several full test bodies are pytest.skip("BUG: …") to document known gaps on main (e.g. retry-after on 429, 529 passthrough, count_tokens field/beta forwarding, truncated streams, Azure supported beta) until product fixes land.

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

  • 12e4a48 passes /live-pr-risk
  • ab52731 passes /live-pr-risk (tests-only commit, the changed-symbol graph under litellm/ is empty)
  • 6e71084 passes /live-pr-risk (tests-only commit plus a clean merge of origin/main, the PR's changed-symbol graph under litellm/ is empty)
  • 52a85d5 passes /live-pr-risk (tests-only commit, the changed-symbol graph under litellm/ is empty)
  • dff0cb2 passes /live-pr-risk (clean merge of origin/main onto 52a85d5, the PR's changed-symbol graph under litellm/ is empty)
  • de0c18a passes /live-pr-risk (clean merge of origin/main onto 7a536b7, the PR's changed-symbol graph under litellm/ is empty)

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

devin-ai-integration Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Adds integration tests for message endpoints.

The PR appears safe to merge based on this review; no new actionable issue was established.

Summary

Adds real-proxy integration tests for Anthropic Messages, Claude Code gateway and OAuth flows, token counting, Skills uploads, and Vertex and Azure AI Claude requests. Known product gaps are retained as skipped tests. The latest commit merges main without changing the seven PR files.

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

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

Stale Bugbot comment from a previous run.

@codecov

codecov Bot commented Oct 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

mateo-berri and others added 2 commits October 6, 2026 01:44
…wlist

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

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

…en and pin the truncated stream bug

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

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

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

Stale Bugbot comment from a previous run.

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

Stale Bugbot comment from a previous run.

@mateo-berri mateo-berri removed the run-ci label Oct 6, 2026
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@litereview

litereview Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

Completed · Some checks not run.

No correctness findings.

The PR changes only test files under tests/integration/**, plus six new BUG skips that keep their full test bodies. It does not modify litellm/llms/** or prompt_templates/**, so the real-testing-evidence gate does not apply.

Checks and execution details
  • Passed · Real testing evidence (required): Not applicable: no LLM translation changes in the scoped paths. All seven changed files are new test modules under tests/integration/ (authorization/test_claude_code_gateway_oauth.py, messages_endpoint/providers/anthropic/test_anthropic_{wire,gateway_wire,count_tokens_wire}.py, providers/test_{anthropic_skills_create,azure_ai_claude_messages,vertex_partner_messages}_wire.py). Nothing under litellm/llms/** or litellm/litellm_core_utils/prompt_templates/** changed.
  • Passed · Syntax and collection of new test modules (optional): py_compile succeeded for all seven files. After uv sync --frozen --all-extras --group dev, pytest --collect-only collected 30 tests from five of the modules. Two modules (test_claude_code_gateway_oauth.py and test_anthropic_gateway_wire.py) failed to import because the existing _support/process.py needs psutil. pyproject.toml pins psutil in a group that sync did not install. The PR did not cause this environment gap.
  • Passed · Placement and skip conventions (optional): The new files live in directories that GROUPS in tests/integration/run.py selects (authorization maps to management; providers and messages_endpoint map to providers). Product bugs use pytest.skip("BUG: ...") at the top of each test body, as tests/integration/AGENTS.md requires. No new covers markers. The OAuth test asserts LITELLM_LICENSE, which .circleci/scripts/run_integration.sh forwards.
  • Not run · Execute integration tests against proxy, Postgres and Redis (optional): Not run: the sandbox has no Postgres or Redis service, and these tests need the CircleCI-owned stack that run_integration.sh starts. This is not required for the scoped evidence rule.

View review · Reviewed de0c18a02d88

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

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

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

Stale Bugbot comment from a previous run.

mateo-berri and others added 2 commits October 14, 2026 04:03
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>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

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

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@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 de0c18a. 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 60ee966 into main Oct 14, 2026
90 checks passed
@mateo-berri
mateo-berri deleted the litellm_endpoint_contracts_anthropic_messages branch October 14, 2026 06:57
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.

1 participant