@@ -3,6 +3,7 @@ import type { OpenClawConfig } from "../config/types.js";
33import { resetLogger , setLoggerOverride } from "../logging/logger.js" ;
44import { createWarnLogCapture } from "../logging/test-helpers/warn-log-capture.js" ;
55import { __testing as setupRegistryRuntimeTesting } from "../plugins/setup-registry.runtime.js" ;
6+ import { __testing as modelSelectionCliTesting } from "./model-selection-cli.js" ;
67import {
78 buildAllowedModelSet ,
89 inferUniqueProviderFromConfiguredModels ,
@@ -157,6 +158,7 @@ describe("model-selection", () => {
157158
158159 describe ( "isCliProvider" , ( ) => {
159160 beforeEach ( ( ) => {
161+ modelSelectionCliTesting . resetCliProviderCache ( ) ;
160162 setupRegistryRuntimeTesting . resetRuntimeState ( ) ;
161163 setupRegistryRuntimeTesting . setRuntimeModuleForTest ( {
162164 resolvePluginSetupCliBackend : ( { backend } ) =>
@@ -170,6 +172,7 @@ describe("model-selection", () => {
170172 } ) ;
171173
172174 afterEach ( ( ) => {
175+ modelSelectionCliTesting . resetCliProviderCache ( ) ;
173176 setupRegistryRuntimeTesting . resetRuntimeState ( ) ;
174177 } ) ;
175178
@@ -180,6 +183,23 @@ describe("model-selection", () => {
180183 it ( "returns false for provider ids" , ( ) => {
181184 expect ( isCliProvider ( "example-cli" , { } as OpenClawConfig ) ) . toBe ( false ) ;
182185 } ) ;
186+
187+ it ( "caches setup registry cli backend lookups" , ( ) => {
188+ const resolvePluginSetupCliBackend = vi . fn ( ( { backend } ) =>
189+ backend === "claude-cli"
190+ ? {
191+ pluginId : "anthropic" ,
192+ backend : { id : "claude-cli" , config : { command : "claude" } } ,
193+ }
194+ : undefined ,
195+ ) ;
196+ setupRegistryRuntimeTesting . setRuntimeModuleForTest ( { resolvePluginSetupCliBackend } ) ;
197+
198+ expect ( isCliProvider ( "claude-cli" , { } as OpenClawConfig ) ) . toBe ( true ) ;
199+ expect ( isCliProvider ( "claude-cli" , { } as OpenClawConfig ) ) . toBe ( true ) ;
200+
201+ expect ( resolvePluginSetupCliBackend ) . toHaveBeenCalledTimes ( 1 ) ;
202+ } ) ;
183203 } ) ;
184204
185205 describe ( "modelKey" , ( ) => {
0 commit comments