Skip to content

fix(bedrock): bearer-token Converse routing + region-scoped picker (#28156) - #64628

Merged
teknium1 merged 4 commits into
mainfrom
salvage/34742-bedrock-bearer
Jul 15, 2026
Merged

fix(bedrock): bearer-token Converse routing + region-scoped picker (#28156)#64628
teknium1 merged 4 commits into
mainfrom
salvage/34742-bedrock-bearer

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Both #28156 bugs fixed: bearer-token Bedrock users no longer crash at runtime (Claude routes through the Converse API instead of the SigV4-only AnthropicBedrock SDK), and the model picker is region-scoped (an EU picker no longer offers us.*/unroutable inference profiles or pins us.anthropic.* recommendations).

Root causes: resolve_runtime_provider unconditionally forced api_mode="anthropic_messages" (→ AnthropicBedrock SDK → SigV4 chain → could not resolve credentials from session) for any Claude model even when the only credential was AWS_BEARER_TOKEN_BEDROCK; and _model_flow_bedrock's dedup/sort only knew us./global. prefixes with a hardcoded us.anthropic.* _RECOMMENDED list.

Changes

  • Salvaged fix(bedrock): streaming fallback to Converse API + image base64 decode + bearer token routing #34742 by @JiaDe-Wu: bearer-token detection routes Claude → bedrock_converse; streaming falls back to converse() on IAM streaming-action denial; image data-URLs decoded to raw bytes before the Converse wire layer (boto3 re-encodes — double-encoding was rejected).
  • hermes_cli/model_setup_flows.py (ours): bedrock_model_routable_from_region() with the full AWS geo-prefix set (us./eu./ap./apac./jp./ca./sa./me./af./global.); picker filters unroutable profiles; recommendations match geo-agnostically on base model id so each region pins its own profile; in-region profiles sort above global.* (the issue thread's ordering complaint); dedup generalized to all profile prefixes.
  • Tests: bearer→Converse routing + SigV4-path regression (monkeypatch-based rewrite of the PR's test), region-scoping matrix (13 tests), image-decode tests from the PR.

Validation

Before After
Bearer-only + Claude runtime crash (SigV4 chain) bedrock_converse (SigV4 setups keep the AnthropicBedrock SDK path)
EU picker us.*/global.* offered + us.* recommended only eu.*/global.*/bare ids; eu.* recommended, in-region above global
tests (bedrock_adapter + region picker + runtime_provider_resolution) 297/297 pass

Salvages #34742 by @JiaDe-Wu (authorship preserved) + our region-scoping half. Fixes #28156. Credit also to @pgregg88 (prefix-set completeness + ordering analysis) and @aleck31 (SigV4 trap confirmation).

Infographic

bedrock-bearer

@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 comp/cli CLI entry point, hermes_cli/, setup wizard provider/bedrock AWS Bedrock (boto3, IAM) P2 Medium — degraded but workaround exists labels Jul 14, 2026
JiaDe-Wu and others added 4 commits July 15, 2026 09:47
…e + bearer token routing

Three fixes for the Bedrock Claude path:

1. Streaming fallback: When AnthropicBedrock SDK raises 'Unexpected event
   order' (SDK misparses Bedrock error events as message_start), auto-switch
   to native Converse API for the rest of the session instead of failing
   after 3 retries.

2. Image base64 decode (#33317): data URL payloads were passed as base64
   strings to source.bytes, but boto3 re-encodes at the wire layer. Now
   decoded to raw bytes before passing to Converse API.

3. Bearer token routing (#28156): Users with AWS_BEARER_TOKEN_BEDROCK are
   now routed through Converse API regardless of model, since the
   AnthropicBedrock SDK only supports SigV4 signing.

3 new tests. 121 bedrock_adapter tests passing.
Rewrites the cherry-picked test to import os locally and monkeypatch the
resolver seams instead of patching bedrock_adapter internals; adds the
inverse assertion (no bearer -> AnthropicBedrock SDK path preserved).
…28156)

Bug 2 of #28156: the picker offered us./global. inference profiles to
EU-region endpoints (unroutable — AWS rejects them regardless of
credentials) and _RECOMMENDED hardcoded us.anthropic.* ids, so non-US
pickers pinned profiles their endpoint can't invoke.

- bedrock_model_routable_from_region(): geo-prefixed profiles are only
  offered in their own geography (full AWS prefix set incl. apac./jp./
  ca./sa./me./af.); bare ids and global.* pass everywhere; unknown
  region shapes hide nothing.
- Recommendations match geo-agnostically on the base model id, so an EU
  picker pins eu.anthropic.claude-sonnet-4-6; in-region geo profiles
  sort above global.* for the same model (addresses the global.*-first
  ordering complaint from the issue thread).
- Dedup generalized from (us., global.) to all profile prefixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock+Claude: wizard accepts Bearer-only setup, runtime fails on missing IAM + picker shows unroutable us./global. profiles in EU region

3 participants