Skip to content

fix(agent): guard switch_model when fallback chain is unset - #15193

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/switch-model-missing-fallback-chain
Closed

LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/switch-model-missing-fallback-chain

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary\n- normalize fallback state at the start of AIAgent.switch_model()\n- avoid crashing when lightweight callers or tests invoke switch_model() without the full init path\n- preserve existing fallback-pruning behavior when switching primary providers\n\n## Why\nRecent CI failures across authored PRs include tests/agent/test_minimax_provider.py::TestMinimaxSwitchModelCredentialGuard::test_switch_to_minimax_does_not_resolve_anthropic_token, which crashes with an AttributeError before the actual credential guard can be verified.\n\nThis patch keeps switch_model() robust for those direct-call paths and removes one shared test failure from the current PR backlog.\n\n## Verification\n- python3.12 direct repro of the failing MiniMax switch_model path now passes without _fallback_chain present\n- python3.12 direct repro of fallback-pruning compatibility still passes

@LeonSGP43
LeonSGP43 force-pushed the fix/switch-model-missing-fallback-chain branch from 412169d to 488e8ab Compare April 24, 2026 14:55
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 24, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Likely duplicate of #14867 — same root cause: switch_model() missing _fallback_chain guard on partially-constructed agents. Also overlaps with merged #15134 which includes consolidated fallback fixes.

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the contribution, @LeonSGP43! This fix was already merged into main via the consolidated fallback/retry PR #15134 (merged 2026-04-24T12:35:44Z), which explicitly credits your earlier PR #14867 as the source.

Evidence:

This is an automated hermes-sweeper review. Closing as implemented on main.

@teknium1 teknium1 closed this Apr 27, 2026
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 P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants