Skip to content

fix(auxiliary): pass extra_body through to Anthropic-wire auxiliary calls - #64942

Merged
teknium1 merged 3 commits into
mainfrom
salvage/37217-anthropic-aux-extra-body
Jul 15, 2026
Merged

fix(auxiliary): pass extra_body through to Anthropic-wire auxiliary calls#64942
teknium1 merged 3 commits into
mainfrom
salvage/37217-anthropic-aux-extra-body

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Caller-supplied extra_body now reaches the Anthropic SDK on the auxiliary wire — vendor request fields configured in auxiliary.<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 /anthropic endpoint).

Salvages the Bug B half of PR #37217 by @dorokuma (authorship preserved). Bug A from the same PR (reasoning_config hardcoded to None) 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-shaped reasoning dict, vLLM-style enable_thinking.

The passthrough is scoped accordingly:

  • Forwards only what the user deliberately configured (or a provider profile deliberately emitted for its own endpoint — minimax/zai thinking fields are valid on their gateways)
  • Excludes reasoning — that key is translated natively into Anthropic thinking by build_anthropic_kwargs; forwarding it raw would 400 every direct-Anthropic aux call (probe-confirmed)
  • Excludes _-prefixed keys — private Hermes plumbing, never wire fields
  • Merges over existing adapter-emitted fields (fast-mode speed) instead of clobbering
  • Nothing Hermes auto-injects can 400; only a user's own invalid config fails — loudly, instead of today's silent drop

Changes

  • agent/auxiliary_client.py (@dorokuma, cherry-picked + conflict-resolved against feat(moa): per-slot reasoning_effort in MoA presets #64631's _reasoning_config plumbing): scoped extra_body merge in _AnthropicCompletionsAdapter.create()
  • Tests (ours): 5 new — passthrough, reasoning/private-key exclusion, merge-over-existing, no-extra_body regression guard, reasoning-only-adds-nothing
  • AUTHOR_MAP entry for dorokuma

Validation

Check Result
tests/agent/test_auxiliary_client.py 321/321 pass
Live API probes (8 extra_body variants, real api.anthropic.com) strict-validation matrix documented above
Live E2E: real call_llm(task=...) → aux Anthropic adapter → real API, config carrying metadata + OpenAI-shaped reasoning in extra_body call succeeded; metadata on the wire, reasoning translated + excluded, zero 400s
Positive + negative control same E2E passes pre-patch (fields silently dropped) and post-patch (fields delivered) — no regression either way

Infographic

Anthropic aux extra_body passthrough

dorokuma and others added 3 commits July 15, 2026 04:44
…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.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists labels Jul 15, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Salvage of the Bug B half of #37217 (authorship preserved). Related to #37217 (predecessor), #64597 (merged — fixed Bug A reasoning_config), and the aux extra_body family #35566 / #60008. Not a duplicate — this is the active salvaged version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants