Repository navigation
The Anthropic provider sends a gateway what it sends Anthropic, and the docs say what LiteLLM needs to pass it on - #1263
Merged
misterjohannesson merged 2 commits intoNov 28, 2026
Conversation
…hropic A loopback stand-in for LiteLLM's /v1/messages and /anthropic routes asserts that the cache_control marks, adaptive thinking's output_config and the thinking-binding anthropic-beta header reach the gateway as the provider sends them direct. Nothing was dropped on Troupe's side. The admin page says what LiteLLM does with them: the pass-through forwards body and headers unchanged; /v1/messages carries the beta to Bedrock as anthropic_beta, the thinking-binding beta from LiteLLM v1.103.0, so an older proxy needs thinking_binding left at default; and drop_params can drop output_config for a model it lists without effort. Signed-off-by: Martin Johannesson <martin.johannesson@it-minds.dk>
Signed-off-by: Martin Johannesson <martin.johannesson@it-minds.dk>
2 of 3 tasks
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.
Closes #1048.
What was there
Three unchecked claims about
apps/troupe_core/lib/troupe/llm/providers/anthropic.exbehind a gateway that speaks Anthropic's Messages API: whethercache_control(D65),output_config(D69) andanthropic-beta, carried into Bedrock'santhropic_betabody field (D92), survive LiteLLM or another such gateway.What was found
Troupe's side: checked, nothing dropped. Nothing in the provider depends on
base_urlexcept which key may go there. A new test (apps/troupe_core/test/troupe/llm/anthropic_gateway_test.exs) points the provider at a stand-in gateway on a real loopback socket, at the proxy root (LiteLLM's/v1/messages, bearer) and at/anthropic(LiteLLM's pass-through,x-api-key). It asserts that the cache marks (last tool, system prompt before the task list, last block of the last two user messages),output_config: {effort: high}withthinking: {type: adaptive, display: summarized, block_binding: {prefix_mismatch_behavior: drop_block}}, the signed thinking block, and the headeranthropic-beta: thinking-binding-controls-2026-08-01all reach the wire as the provider sends them to Anthropic. These tests pass before the change, because nothing is dropped. They go in as the check the issue asks for. To confirm they catch a drop, I emptiedbinding_header/1for one run: 2 of the 4 failed onanthropic-beta. The provider is unchanged.LiteLLM's side, read at
BerriAI/litellm@ccb97776b1(main, 2026-11-28):/anthropicpass-through forwards the body unchanged and the caller's headers apart from LiteLLM's own secrets. Its "What Does NOT Change" list starts with "Request body" (architecture.md). The route is"/anthropic/{endpoint:path}"(llm_passthrough_endpoints.py#L1492-L1497), and its headers come fromcaller_headers_without_litellm_secrets(...)(#L3561-L3587)./v1/messages, the proxy copiesANTHROPIC_API_HEADERS = {"anthropic-version", "anthropic-beta"}(types/llms/anthropic.py#L863-L866) into aProviderSpecificHeaderforanthropic, bedrock, bedrock_mantle, vertex_ai(litellm_pre_call_utils.py#L5013-L5019, #L5039-L5066).user_beta_set: Final = set(get_anthropic_beta_from_headers(headers)), filters them throughfilter_and_transform_beta_headers, and writes what is left asanthropic_messages_request["anthropic_beta"] = filtered_betas(anthropic_claude_transformation.py#L548, #L603-L626, #L815-L816). A beta with no entry is dropped, with the warning "dropping unsupported anthropic-beta values".bedrockcolumn maps"thinking-binding-controls-2026-08-01": "thinking-binding-controls-2026-08-01"(anthropic_beta_headers_config.json#L229). The entry came in with BerriAI/litellm#41203, merged 2026-09-18. Its commit message says the header was dropped before, "so Bedrock and Vertex reject the request with 'thinking.adaptive.block_binding: Extra inputs are not permitted'". I compared against tags: v1.102.1 has no entry and v1.103.0 (2026-09-28) is the first release with it. On that release,thinking.block_bindingis stripped only where no active beta unlocks it (anthropic_beta_gated_fields.py#L47, #L71-L73).cache_controlon Bedrock: onlyscopeand an unsupportedttlare removed (#L171-L210). Troupe sends{type: ephemeral}alone, so its marks pass.output_configon Bedrock is on the Invoke allowlist (output_config: dict, types/llms/bedrock.py#L1242-L1284). An effort above the model's ceiling is lowered bynormalize_bedrock_opus_output_config_effort(#L789-L796). It is dropped only whenlitellm.drop_params is Trueand the model is not one LiteLLM lists as taking an effort (#L844-L855)./v1/messagesdoes not pass Anthropic'smetadataon (# TODO: Add Anthropic \metadata` support, [anthropic/messages/native/transformation.py#L157](https://github.com/BerriAI/litellm/blob/ccb97776b12b23392c77c0837d471b6dbcb3f5bd/litellm/llms/anthropic/messages/native/transformation.py#L157)). The session owner'suser_id` therefore stops at the gateway.What changed
apps/troupe_core/test/troupe/llm/anthropic_gateway_test.exs: the check described above (4 tests).docs/admin/integrations.md§5 now has a bullet on whatanthropicsends a gateway. It covers both LiteLLM routes, the Bedrock beta-to-anthropic_betapath and the minimum version for the thinking-binding beta (v1.103.0). Behind an older proxy,thinking_bindingmust stay atdefault. It also coverslitellm_settings.drop_params: trueandoutput_config, and thatmetadatais not passed on.docs/user/configuration/providers.md: the Anthropic-gateway paragraph says where a LiteLLM proxy takes the call and links to the admin section.No provider change. LiteLLM needs no header or body shape that Troupe does not send. The one condition, the proxy version when
thinking_bindingis set, is a gateway setting, so it is documented rather than worked around.Verified
Root
wslx env KUBECONFIG=<empty file> mix check, run before the merge of the chunk branch:The 12 core failures are the known WSL
rg-shim ones: FileToolsTest grep/list_files ×6, ReadRootsTest, ReadOutputTest, PathOnlyLookupTest, BenchTest ×2 and DoctorTest's bench line. None is inllm/.After merging
development-2026-11-28-2, the following still pass:mix test test/troupe/llm:Result: 194 passed (13 doctests, 181 tests).mix credo --strict:21521 mods/funs, found no issues.mix format --check-formatted: clean.decision-citations: "3 file(s) changed ..., none adds a decision number to code".doc-size: "765 Markdown files, none past 400 lines".doc-links: "1171 links in 765 files".mkdocs build --strict: built.Decisions
Read:
mix troupe.decisions --for apps/troupe_core/lib/troupe/llm/providers/anthropic.ex. The ones that bear on this: 770 (cache marks), 805/815/863 (thinking kept, binding beta, mismatch header) and 787 (metadata). None is changed. None was taken: no behaviour changes, so this is a check and a doc.Left
cache_controloroutput_confighandling.