You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#124923 with a narrow Bedrock-only request-shaping change plus regression coverage.
Two failures are addressed:
AnthropicBedrock structured-output 400s. The auxiliary Anthropic adapter currently translates OpenAI-style response_format into Anthropic output_config.format. That is valid on native/compatible Anthropic Messages routes, but AWS Bedrock's Anthropic endpoint rejects the field with output_config.format: Extra inputs are not permitted.
This PR marks the AnthropicBedrock route explicitly when the Bedrock client is constructed and suppresses the translation only for that route. Native Anthropic / compatible Messages routes continue to receive structured output, and the Bedrock Mantle/OpenAI route is untouched.
Bedrock context probe uses an invalid output minimum.probe_bedrock_context_length() sends maxTokens=8; OpenAI-on-Bedrock models reject output caps below 16 before the prompt-length validation runs, so Hermes never reaches the parseable length error and falls back to the generic 128K context value. The probe now sends maxTokens=16.
Root cause
The structured-output capability decision was being made at the generic Anthropic adapter layer without carrying the fact that this specific Messages client was created for AnthropicBedrock. A provider-wide Bedrock capability flag would be too broad because the same provider slug also owns Mantle/OpenAI and Converse paths.
The context probe independently used an output cap below the minimum accepted by OpenAI-on-Bedrock models, masking the validation error it intentionally provokes.
Changes
agent/auxiliary_client.py
carry an explicit is_bedrock marker from the Bedrock client-construction boundary;
skip response_format -> output_config.format only for AnthropicBedrock;
preserve existing translation for native Anthropic / partner Messages routes.
agent/bedrock_adapter.py
raise the context-probe output cap from 8 to 16.
tests/agent/test_bedrock_issue_124923.py
Bedrock route omits output_config.format;
native Anthropic still translates structured output;
context probe sends maxTokens=16 and still parses the provider-reported maximum.
Competing work / provenance
There is overlapping open work in #124931 for the same issue. I am linking it explicitly rather than presenting this as undiscovered territory.
This implementation was developed independently and does not cherry-pick, copy, or reuse commits from #124931 or any other PR. The main implementation difference is ownership: this branch carries an explicit Bedrock-route marker from _build_bedrock_client() instead of inferring Bedrock from the runtime class name inside the generic Anthropic adapter.
No claim is made that the competing PR is broken; maintainers can choose whichever boundary they prefer.
Exact-head validation
Base: 20f01a0cf6d2dbca6141207abb800520c84fbc86
Branch range is exactly one author-owned commit on that base:
21de4de005655607593773efa4133ca6a3d4ee56 — fix(bedrock): avoid invalid aux request parameters
Changed files are limited to the two production owners and one focused regression module.
Sibling invariants: rejected the tempting provider-wide unsupported_response_formats fix because Bedrock spans AnthropicBedrock, Converse, and Mantle/OpenAI; the final change scopes only the rejecting AnthropicBedrock route and preserves native Anthropic structured output.
Post-implementation / drift: re-checked the final diff, rebased the single commit onto current upstream main, re-searched competing work, and confirmed the branch is exactly one commit ahead with no unrelated files.
The regression tests are committed; I am not claiming a local pytest run from this connector-only environment. Hosted CI on the PR head is the execution gate.
AI code review — automated follow-up for reference; not a maintainer.
The is_bedrock gate works for its target: driving the real _AnthropicCompletionsAdapter.create() with is_bedrock=True and a json_schema format, output_config.format is gone while native routes keep it. Two P2 gaps remain, both in agent/auxiliary_client.py.
1. output_config.effort still ships to the endpoint you are shielding (k<N). The gate wraps only _translate_anthropic_response_format at L1781/L1785. build_anthropic_kwargs runs earlier at L1750, and for an adaptive-thinking model its _thinking_kwargs writes output_config: {"effort": ...} directly (agent/anthropic_adapter.py:601) — never gated. Captured from the real create() path, head 21de4de:
If Bedrock rejects the output_config object, Claude 4.6+ on Bedrock with reasoning still 400s — the same failure, one key narrower. Gate the object, not the translate call.
2. The new test cannot catch #1.test_anthropic_bedrock_omits_structured_output_format asserts "format" not in (kwargs.get("output_config") or {}), which passes while effort remains, and it never sets reasoning, so the adaptive branch never runs. Its other two assertions already hold on base d6864ba — the passthrough filter k not in {"reasoning", "response_format"} is pre-existing. Please confirm by asserting the key set is empty with reasoning on.
3. Detection is a caller flag, not a capability check (please confirm).is_bedrock=True is passed at one of six AnthropicAuxiliaryClient(...) sites (L4833); L1963, L2914, L3084, L5220 default to False. A named custom provider with api_mode=anthropic_messages aimed at a Bedrock-runtime URL takes the L5220 path and gets is_bedrock=False. If reachable, a class-name or base_url check (as #124931 does) avoids a new call-site obligation.
Relation to #124931: same root cause and files, so this covers only what neither closes.
Unverified / please confirm: 1-2 come from running the adapter on the head blob (anthropic_adapter.py verified byte-identical to base); no live Bedrock call was made, so whether the endpoint rejects output_config whole or only format is inferred from #124931. 3 is read from call sites, not executed.
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
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
Fixes #124923 with a narrow Bedrock-only request-shaping change plus regression coverage.
Two failures are addressed:
AnthropicBedrock structured-output 400s. The auxiliary Anthropic adapter currently translates OpenAI-style
response_formatinto Anthropicoutput_config.format. That is valid on native/compatible Anthropic Messages routes, but AWS Bedrock's Anthropic endpoint rejects the field withoutput_config.format: Extra inputs are not permitted.This PR marks the AnthropicBedrock route explicitly when the Bedrock client is constructed and suppresses the translation only for that route. Native Anthropic / compatible Messages routes continue to receive structured output, and the Bedrock Mantle/OpenAI route is untouched.
Bedrock context probe uses an invalid output minimum.
probe_bedrock_context_length()sendsmaxTokens=8; OpenAI-on-Bedrock models reject output caps below 16 before the prompt-length validation runs, so Hermes never reaches the parseable length error and falls back to the generic 128K context value. The probe now sendsmaxTokens=16.Root cause
The structured-output capability decision was being made at the generic Anthropic adapter layer without carrying the fact that this specific Messages client was created for AnthropicBedrock. A provider-wide Bedrock capability flag would be too broad because the same provider slug also owns Mantle/OpenAI and Converse paths.
The context probe independently used an output cap below the minimum accepted by OpenAI-on-Bedrock models, masking the validation error it intentionally provokes.
Changes
agent/auxiliary_client.pyis_bedrockmarker from the Bedrock client-construction boundary;response_format -> output_config.formatonly for AnthropicBedrock;agent/bedrock_adapter.pytests/agent/test_bedrock_issue_124923.pyoutput_config.format;maxTokens=16and still parses the provider-reported maximum.Competing work / provenance
There is overlapping open work in #124931 for the same issue. I am linking it explicitly rather than presenting this as undiscovered territory.
This implementation was developed independently and does not cherry-pick, copy, or reuse commits from #124931 or any other PR. The main implementation difference is ownership: this branch carries an explicit Bedrock-route marker from
_build_bedrock_client()instead of inferring Bedrock from the runtime class name inside the generic Anthropic adapter.No claim is made that the competing PR is broken; maintainers can choose whichever boundary they prefer.
Exact-head validation
Base:
20f01a0cf6d2dbca6141207abb800520c84fbc86Branch range is exactly one author-owned commit on that base:
21de4de005655607593773efa4133ca6a3d4ee56—fix(bedrock): avoid invalid aux request parametersChanged files are limited to the two production owners and one focused regression module.
Three blocker passes
unsupported_response_formatsfix because Bedrock spans AnthropicBedrock, Converse, and Mantle/OpenAI; the final change scopes only the rejecting AnthropicBedrock route and preserves native Anthropic structured output.main, re-searched competing work, and confirmed the branch is exactly one commit ahead with no unrelated files.The regression tests are committed; I am not claiming a local pytest run from this connector-only environment. Hosted CI on the PR head is the execution gate.
Infographic