TypeScript
fix(server): ACP agents that need no sign-in drop models they stopped advertising (#18807)
Igor Makowski3adac9403fd8
diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.tsindex b3e17fac371..9b9f2b60c98 100644--- a/apps/server/src/provider/ProviderRegistry.test.ts+++ b/apps/server/src/provider/ProviderRegistry.test.ts@@ -849,6 +849,7 @@ it.layer(},{ slug: "default", name: "Default", isCustom: false, capabilities: null },],+ nativeSessions: { canList: false, canLoad: false, canResume: false },slashCommands: [],skills: [],} as const satisfies ServerProvider;@@ -864,6 +865,37 @@ it.layer();});+ it("drops stale ACP Registry models when an agent without sign-in completes discovery", () => {+ const previousProvider = {+ instanceId: ProviderInstanceId.make("acpRegistry_kimi"),+ driver: ProviderDriverKind.make("acpRegistry"),+ status: "ready",+ enabled: true,+ installed: true,+ auth: { status: "unknown", canLogout: false },+ checkedAt: "2026-08-13T00:00:00.000Z",+ version: "1.2.0",+ models: [+ { slug: "kimi-old", name: "Kimi Old", isCustom: false, capabilities: null },+ { slug: "default", name: "Default", isCustom: false, capabilities: null },+ ],+ nativeSessions: { canList: true, canLoad: true, canResume: false },+ slashCommands: [],+ skills: [],+ } as const satisfies ServerProvider;+ // Agents that advertise no auth methods stay "unknown" after every probe.+ const probedProvider = {+ ...previousProvider,+ checkedAt: "2026-08-13T00:01:00.000Z",+ models: [{ slug: "kimi-new", name: "Kimi New", isCustom: false, capabilities: null }],+ } satisfies ServerProvider;++ assert.deepStrictEqual(+ ProviderRegistry.mergeProviderSnapshot(previousProvider, probedProvider).models,+ [...probedProvider.models],+ );+ });+it("retains ACP Registry models while discovery has not completed", () => {const previousProvider = {instanceId: ProviderInstanceId.make("acpRegistry_codex"),@@ -882,11 +914,19 @@ it.layer(...previousProvider,checkedAt: "2026-08-13T00:01:00.000Z",auth: { status: "unknown" },+ message: "Checking ACP authentication, models, and commands in the background...",models: [{ slug: "default", name: "Default", isCustom: false, capabilities: null }],} satisfies ServerProvider;+ // A saved sign-in confirmation marks the readiness snapshot authenticated+ // before discovery has run.+ const confirmedCheckingProvider = {+ ...checkingProvider,+ auth: { status: "authenticated" },+ } satisfies ServerProvider;const failedProbeProvider = {...checkingProvider,status: "warning",+ message: "ACP discovery failed.",} satisfies ServerProvider;assert.deepStrictEqual(@@ -896,6 +936,13 @@ it.layer({ slug: "gpt-5.6-sol", name: "GPT-5.6-Sol", isCustom: false, capabilities: null },],);+ assert.deepStrictEqual(+ ProviderRegistry.mergeProviderSnapshot(previousProvider, confirmedCheckingProvider).models,+ [+ { slug: "default", name: "Default", isCustom: false, capabilities: null },+ { slug: "gpt-5.6-sol", name: "GPT-5.6-Sol", isCustom: false, capabilities: null },+ ],+ );assert.deepStrictEqual(ProviderRegistry.mergeProviderSnapshot(previousProvider, failedProbeProvider).models,[diff --git a/apps/server/src/provider/ProviderRegistry.ts b/apps/server/src/provider/ProviderRegistry.tsindex 80382fc1927..bf057107373 100644--- a/apps/server/src/provider/ProviderRegistry.ts+++ b/apps/server/src/provider/ProviderRegistry.ts@@ -157,14 +157,16 @@ const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean =>if (provider.driver === ProviderDriverKind.make("acpRegistry")) {// ACP Registry discovery probes return the agent's complete inventory, so- // a completed probe (ready and authenticated) replaces the model list —- // otherwise agents that rename or collapse models leave stale entries- // pinned forever through the snapshot cache. Readiness-only and failed- // probe snapshots only know the "default" placeholder and stay partial.+ // a completed probe replaces the model list — otherwise agents that rename+ // or collapse models leave stale entries pinned forever through the+ // snapshot cache. Only a completed probe reports `nativeSessions`;+ // readiness-only and failed probe snapshots only know the "default"+ // placeholder and stay partial. Auth is no signal here: agents without+ // sign-in stay "unknown" after every probe.return !(provider.installed &&provider.status === "ready" &&- provider.auth.status === "authenticated"+ provider.nativeSessions !== undefined);}