@@ -155,6 +155,7 @@ describe("fallback-state", () => {
155155 fallbackNoticeActiveModel : "claude-cli/claude-opus-4-7" ,
156156 fallbackNoticeReason : "selected model unavailable" ,
157157 } ,
158+ cfg : { } ,
158159 } ) ;
159160
160161 expect ( resolved . fallbackActive ) . toBe ( false ) ;
@@ -164,6 +165,47 @@ describe("fallback-state", () => {
164165 expect ( resolved . nextState . activeModel ) . toBeUndefined ( ) ;
165166 } ) ;
166167
168+ it ( "does not repeat runtime alias comparison when persisted fallback refs match" , ( ) => {
169+ let setupBackendLookups = 0 ;
170+ cliBackendsTesting . setDepsForTest ( {
171+ resolvePluginSetupCliBackend : ( { backend } ) => {
172+ setupBackendLookups += 1 ;
173+ return backend === "claude-cli"
174+ ? {
175+ pluginId : "anthropic" ,
176+ backend : {
177+ id : "claude-cli" ,
178+ modelProvider : "anthropic" ,
179+ config : { command : "claude" } ,
180+ bundleMcp : false ,
181+ } ,
182+ }
183+ : undefined ;
184+ } ,
185+ resolvePluginSetupRegistry : ( ) => {
186+ throw new Error ( "full setup registry should not load for a single runtime alias" ) ;
187+ } ,
188+ resolveRuntimeCliBackends : ( ) => [ ] ,
189+ } ) ;
190+
191+ const resolved = resolveFallbackTransition ( {
192+ selectedProvider : "anthropic" ,
193+ selectedModel : "claude-opus-4-7" ,
194+ activeProvider : "claude-cli" ,
195+ activeModel : "claude-opus-4-7" ,
196+ attempts : [ ] ,
197+ state : {
198+ fallbackNoticeSelectedModel : "anthropic/claude-opus-4-7" ,
199+ fallbackNoticeActiveModel : "claude-cli/claude-opus-4-7" ,
200+ fallbackNoticeReason : "selected model unavailable" ,
201+ } ,
202+ cfg : { } ,
203+ } ) ;
204+
205+ expect ( resolved . fallbackActive ) . toBe ( false ) ;
206+ expect ( setupBackendLookups ) . toBe ( 2 ) ;
207+ } ) ;
208+
167209 it ( "does not build a fallback notice for equivalent CLI runtime aliases" , ( ) => {
168210 registerAnthropicCliBackendForTest ( ) ;
169211
0 commit comments