fix(auxiliary): pass extra_body through to Anthropic-wire auxiliary calls - #64942
Merged
Conversation
…iary Anthropic calls
Two related bugs in _AnthropicCompletionsAdapter.create() in
agent/auxiliary_client.py silently discard caller-supplied
reasoning_config and extra_body on the Anthropic-Messages
auxiliary-protocol path:
* Bug A: reasoning_config=None was hardcoded at L1000, so the
reasoning_config parameter on build_anthropic_kwargs was
unreachable for any auxiliary task. The main agent path
(agent/transports/anthropic.py) already reads
reasoning_config from caller params; this PR aligns the
auxiliary adapter with the same pattern.
* Bug B: create(**kwargs) accepts an OpenAI-style kwargs
payload from the caller but only forwards a hand-picked
subset to self._client.messages.create(). Any caller-supplied
extra_body (e.g. thinking control, metadata, service_tier,
vendor-specific fields) was dropped on the floor. The
codex/responses transport in the same file already merges
extra_body; the Anthropic branch is the gap.
This unlocks the caller-supplied extra_body path so auxiliary
callers can set per-vendor request fields (including
thinking: {type: "disabled"} for Anthropic-compatible vendors
that require an explicit disable on the wire), and lets the
reasoning_config kwarg flow into build_anthropic_kwargs like the
main agent does. Both changes are backward-compatible for
callers that don't pass the affected kwargs.
Affected providers (all routed through _AnthropicCompletionsAdapter
via _maybe_wrap_anthropic): anthropic (native), minimax /
minimax-cn, kimi-coding / kimi-coding-cn, z.ai / GLM, and any
custom /anthropic-suffixed endpoint. See PR description for
related issues (#35566, #7209, #16533, #32813, #29248).
…sions) Five tests for the salvaged #37217 Bug B fix: vendor-field passthrough, reasoning-key + private-key exclusion, merge-over-existing (fast-mode speed), no-extra_body regression guard, reasoning-only adds nothing. Live probes against api.anthropic.com informed the exclusion design: Anthropic strictly validates the request body (unknown keys 400 with 'Extra inputs are not permitted'), so the passthrough forwards only caller-configured fields and never the OpenAI-shaped reasoning dict (translated natively) or _-private plumbing keys.
Collaborator
This was referenced Jul 15, 2026
Closed
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.
Summary
Caller-supplied
extra_bodynow reaches the Anthropic SDK on the auxiliary wire — vendor request fields configured inauxiliary.<task>.extra_body(thinking control, metadata, gateway-specific fields) were previously discarded for every aux task routed through Anthropic Messages (anthropic, minimax, zai vision, any/anthropicendpoint).Salvages the Bug B half of PR #37217 by @dorokuma (authorship preserved). Bug A from the same PR (
reasoning_confighardcoded toNone) was independently fixed by #64597/#64631.Wire safety (the merge-blocking question)
Live probes against the real Anthropic API before writing anything: the Messages API strictly validates the request body — unknown keys 400 with "Extra inputs are not permitted". Accepted:
metadata,thinking. Rejected: any unknown key, the OpenAI-shapedreasoningdict, vLLM-styleenable_thinking.The passthrough is scoped accordingly:
thinkingfields are valid on their gateways)reasoning— that key is translated natively into Anthropicthinkingbybuild_anthropic_kwargs; forwarding it raw would 400 every direct-Anthropic aux call (probe-confirmed)_-prefixed keys — private Hermes plumbing, never wire fieldsspeed) instead of clobberingChanges
agent/auxiliary_client.py(@dorokuma, cherry-picked + conflict-resolved against feat(moa): per-slot reasoning_effort in MoA presets #64631's_reasoning_configplumbing): scoped extra_body merge in_AnthropicCompletionsAdapter.create()Validation
tests/agent/test_auxiliary_client.pycall_llm(task=...)→ aux Anthropic adapter → real API, config carryingmetadata+ OpenAI-shapedreasoningin extra_bodyInfographic