From 771571aee468258b0883b5ae2cf9ba1a4053bbad Mon Sep 17 00:00:00 2001 From: dorokuma Date: Tue, 2 Jun 2026 12:59:02 +0800 Subject: [PATCH] fix(auxiliary): pass reasoning_config and extra_body through to auxiliary 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). --- agent/auxiliary_client.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 2b91b9e4d8e6..5f2d7e806aed 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -1337,6 +1337,31 @@ class _AnthropicCompletionsAdapter: if not _forbids_sampling_params(model): anthropic_kwargs["temperature"] = temperature + # Pass through caller-supplied extra_body so providers behind + # Anthropic-compatible gateways receive their per-vendor request + # fields (thinking control, metadata, portal tags, ...). The dict + # form is the documented Anthropic SDK passthrough for non-standard + # request body keys; merge on top of whatever build_anthropic_kwargs + # already produced (e.g. fast-mode ``speed``) so call-time settings + # survive. Two exclusions: + # - ``reasoning``: the OpenAI-shaped config dict is TRANSLATED into + # the native ``thinking`` field above (build_anthropic_kwargs); + # forwarding the raw field alongside would double-specify + # reasoning and 400 on strict gateways. + # - ``_``-prefixed keys: private Hermes plumbing (_reasoning_config + # et al.), never wire fields. + caller_extra_body = kwargs.get("extra_body") + if caller_extra_body and isinstance(caller_extra_body, dict): + passthrough = { + k: v for k, v in caller_extra_body.items() + if k != "reasoning" and not str(k).startswith("_") + } + if passthrough: + existing = anthropic_kwargs.get("extra_body") or {} + if not isinstance(existing, dict): + existing = {} + anthropic_kwargs["extra_body"] = {**existing, **passthrough} + response = create_anthropic_message(self._client, anthropic_kwargs) _transport = get_transport("anthropic_messages") _nr = _transport.normalize_response(