Skip to content

fix(bedrock): preserve regional runtime on model switch - #65433

Closed
rasitakyol wants to merge 1 commit into
NousResearch:mainfrom
rasitakyol:agent/bedrock-regional-model-switch
Closed

fix(bedrock): preserve regional runtime on model switch#65433
rasitakyol wants to merge 1 commit into
NousResearch:mainfrom
rasitakyol:agent/bedrock-regional-model-switch

Conversation

@rasitakyol

Copy link
Copy Markdown
Contributor

What does this PR do?

Restores the Bedrock-specific runtime when /model switches into AWS Bedrock mid-session. Regional inference profiles now keep their resolved AWS region, Claude models rebuild through AnthropicBedrock, Converse models avoid constructing an OpenAI client, and a failed rebuild rolls the prior Bedrock region/runtime back atomically.

This salvages #41322 on current main while preserving BROCCOLO1D's commit authorship. The older PR's runtime_provider.py change is intentionally omitted because current main already routes Bedrock from target_model.

Related Issue

Fixes #41296

Salvages #41322 with original author credit preserved.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Security fix
  • Documentation update
  • Tests (adding or improving test coverage)
  • Refactor (no behavior 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

  1. Configure Bedrock for a non-us-east-1 region and start Hermes on a non-Bedrock provider.

  2. Switch to a regional Claude profile with /model ... --provider bedrock; verify the AnthropicBedrock client receives the resolved region.

  3. Switch to a non-Claude Bedrock model; verify the Converse path does not build an OpenAI client.

  4. Run:

    scripts/run_tests.sh -j 6 tests/run_agent/test_switch_model_*.py tests/hermes_cli/test_runtime_provider_resolution.py -q
    

Result after rebasing onto current main: 180 passed.

Additional validation:

  • full repository Python suite: 41,370 passed, 28 failed in 14 unrelated environment/platform files
  • changed test files: 9/9 passed
  • model-switch group: 29/29 passed
  • runtime-provider resolution: 151/151 passed
  • relevant Bedrock adapter, transport, integration, picker, regional-picker, 1M-context, and interrupt-worker groups passed
  • Ruff, Windows-footgun scan, and git diff --check passed

The 28 repository-wide failures are outside this diff and fall into existing macOS-vs-WSL/systemd assumptions, /tmp canonicalization/mode differences, shared import/mock isolation, and subprocess timing. No changed or Bedrock/model-switch test failed.

Checklist

Code

  • I've read the Contributing Guide.
  • My commit follows Conventional Commits.
  • I searched existing PRs and issues; this is an attributed salvage of closed fix(bedrock): preserve regional runtime on model switch #41322, not a duplicate of an active PR.
  • My PR contains only changes related to this fix.
  • The complete local Python suite is green (see the 28 unrelated environment/platform failures above).
  • I've added tests for my changes.
  • Tested on macOS 26.5.2 with Python 3.11.

Documentation and Housekeeping

  • Documentation update: N/A; no user-facing configuration changed.
  • cli-config.yaml.example: N/A.
  • Architecture/workflow docs: N/A.
  • Cross-platform impact considered; no platform-specific I/O changed.
  • Tool descriptions/schemas: 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.

@rasitakyol
rasitakyol marked this pull request as ready for review July 16, 2026 07:07
@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 P2 Medium — degraded but workaround exists labels Jul 16, 2026
@rasitakyol rasitakyol closed this Jul 17, 2026
@rasitakyol
rasitakyol deleted the agent/bedrock-regional-model-switch branch July 17, 2026 06:19
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 P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

3 participants