fix(bedrock): preserve regional runtime on model switch - #65433
Closed
rasitakyol wants to merge 1 commit into
Closed
fix(bedrock): preserve regional runtime on model switch#65433rasitakyol wants to merge 1 commit into
rasitakyol wants to merge 1 commit into
Conversation
rasitakyol
marked this pull request as ready for review
July 16, 2026 07:07
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.
What does this PR do?
Restores the Bedrock-specific runtime when
/modelswitches into AWS Bedrock mid-session. Regional inference profiles now keep their resolved AWS region, Claude models rebuild throughAnthropicBedrock, Converse models avoid constructing an OpenAI client, and a failed rebuild rolls the prior Bedrock region/runtime back atomically.This salvages #41322 on current
mainwhile preserving BROCCOLO1D's commit authorship. The older PR'sruntime_provider.pychange is intentionally omitted because currentmainalready routes Bedrock fromtarget_model.Related Issue
Fixes #41296
Salvages #41322 with original author credit preserved.
Type of Change
Changes Made
agent/agent_runtime_helpers.py: snapshots_bedrock_region, rebuilds Bedrock Anthropic/Converse state from the resolved regional endpoint, and clears incompatible client state.tests/run_agent/test_switch_model_context.py: covers regional Claude/AnthropicBedrock and Nova/Converse switches.tests/run_agent/test_switch_model_rollback.py: covers failed regional client rebuild rollback.How to Test
Configure Bedrock for a non-
us-east-1region and start Hermes on a non-Bedrock provider.Switch to a regional Claude profile with
/model ... --provider bedrock; verify the AnthropicBedrock client receives the resolved region.Switch to a non-Claude Bedrock model; verify the Converse path does not build an OpenAI client.
Run:
Result after rebasing onto current
main: 180 passed.Additional validation:
git diff --checkpassedThe 28 repository-wide failures are outside this diff and fall into existing macOS-vs-WSL/systemd assumptions,
/tmpcanonicalization/mode differences, shared import/mock isolation, and subprocess timing. No changed or Bedrock/model-switch test failed.Checklist
Code
Documentation and Housekeeping
cli-config.yaml.example: N/A.Screenshots / Logs
No UI changes. A live AWS Bedrock call was not made; region/client routing and rollback are covered with behavior tests.