fix(agent): initialize Bedrock clients on model switch - #67970
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for preserving the Bedrock initialization and rollback state. The underlying runtime gap is still present on current main, but a current pipeline change prevents the Claude half of this patch from being used by normal /model switches.
Problems
hermes_cli/runtime_provider.py:2120-2133resolves Claude-on-Bedrock asanthropic_messages, buthermes_cli/model_switch.py:1475-1477then unconditionally applies the Bedrock host mode fromhermes_cli/providers.py:601-602, changing it tobedrock_converse. Consequently, the new AnthropicBedrock branch is not reached for a standard Claude/modelswitch.- The added tests pass
api_modedirectly toagent.switch_model(), so they do not exercise that resolution-and-override path.
Suggested changes
- Preserve the resolved Claude Bedrock
anthropic_messagesmode through the model-switch pipeline, while retaining Converse for non-Claude targets. - Add an end-to-end regression covering both Claude and non-Claude Bedrock switches through
hermes_cli.model_switch.switch_model()and the live-agent runtime switch.
Automated hermes-sweeper review.
| agent._client_kwargs = {} | ||
| agent.client = MoAClient(agent.model or "default") | ||
| elif (new_provider or "").strip().lower() == "bedrock": | ||
| # Bedrock does not expose an OpenAI-compatible endpoint. Mirror |
There was a problem hiding this comment.
This branch is correct only if api_mode reaches it as anthropic_messages. On current main, the normal /model pipeline resolves Claude Bedrock as Messages in hermes_cli/runtime_provider.py:2120-2133 but then overwrites it to bedrock_converse in hermes_cli/model_switch.py:1475-1477. Please preserve the resolved Claude mode and add a pipeline-level regression; the direct helper test alone cannot catch this.
SummaryTwenty-five PRs address or reference this issue complex across context-length ownership and persistence, Desktop assignment, Related pull requests
Duplicates#21509 is the narrower duplicate of #22387, whose implementation was merged through #24724; #17245 is the narrow precursor to the broader #17269 approach; #59191 is a closed duplicate of canonical #59125; and #41322 → #65433 → #67948 → #67970 is the Bedrock salvage/refile chain, with #67948 directly superseded by #67970. Suggested consolidationAuthor action: rebase #67970 onto main, preserve Claude Bedrock's resolved Complex graphflowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
I41296(["issue #41296 (open)"])
subgraph Dup41322 ["PRs duplicating each other"]
P41322["PR #41322 (closed)"]
P65433["PR #65433 (closed)"]
P67948["PR #67948 (closed)"]
P67970["PR #67970 (open)"]
end
P67970 -->|best fix| I41296
class I41296 open
class P41322 closed
class P65433 closed
class P67948 closed
class P67970 open
class P41322 best
class P65433 best
class P67970 best
class P67970 target
click I41296 "https://github.com/NousResearch/hermes-agent/issues/41296"
click P41322 "https://github.com/NousResearch/hermes-agent/pull/41322"
click P65433 "https://github.com/NousResearch/hermes-agent/pull/65433"
click P67948 "https://github.com/NousResearch/hermes-agent/pull/67948"
click P67970 "https://github.com/NousResearch/hermes-agent/pull/67970"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label). Cross-PR triage: Reviewed 25 pull requests and 7 issues in this complex. Each diff was read against this issue; Assessment working set: 136 kB of PR diffs, 70 kB of issue/PR text, 32 kB of discussion (47 comments), 54 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
Summary
Fixes #41296 for the remaining initialization gap when switching to AWS Bedrock during a live session.
Validation