Skip to content

Commit 3adac94

Browse files
authored
fix(server): ACP agents that need no sign-in drop models they stopped advertising (#18807)
1 parent ffa343b commit 3adac94

2 files changed

Lines changed: 54 additions & 5 deletions

File tree

‎apps/server/src/provider/ProviderRegistry.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ it.layer(
849849
},
850850
{ slug: "default", name: "Default", isCustom: false, capabilities: null },
851851
],
852+
nativeSessions: { canList: false, canLoad: false, canResume: false },
852853
slashCommands: [],
853854
skills: [],
854855
} as const satisfies ServerProvider;
@@ -864,6 +865,37 @@ it.layer(
864865
);
865866
});
866867

868+
it("drops stale ACP Registry models when an agent without sign-in completes discovery", () => {
869+
const previousProvider = {
870+
instanceId: ProviderInstanceId.make("acpRegistry_kimi"),
871+
driver: ProviderDriverKind.make("acpRegistry"),
872+
status: "ready",
873+
enabled: true,
874+
installed: true,
875+
auth: { status: "unknown", canLogout: false },
876+
checkedAt: "2026-08-13T00:00:00.000Z",
877+
version: "1.2.0",
878+
models: [
879+
{ slug: "kimi-old", name: "Kimi Old", isCustom: false, capabilities: null },
880+
{ slug: "default", name: "Default", isCustom: false, capabilities: null },
881+
],
882+
nativeSessions: { canList: true, canLoad: true, canResume: false },
883+
slashCommands: [],
884+
skills: [],
885+
} as const satisfies ServerProvider;
886+
// Agents that advertise no auth methods stay "unknown" after every probe.
887+
const probedProvider = {
888+
...previousProvider,
889+
checkedAt: "2026-08-13T00:01:00.000Z",
890+
models: [{ slug: "kimi-new", name: "Kimi New", isCustom: false, capabilities: null }],
891+
} satisfies ServerProvider;
892+
893+
assert.deepStrictEqual(
894+
ProviderRegistry.mergeProviderSnapshot(previousProvider, probedProvider).models,
895+
[...probedProvider.models],
896+
);
897+
});
898+
867899
it("retains ACP Registry models while discovery has not completed", () => {
868900
const previousProvider = {
869901
instanceId: ProviderInstanceId.make("acpRegistry_codex"),
@@ -882,11 +914,19 @@ it.layer(
882914
...previousProvider,
883915
checkedAt: "2026-08-13T00:01:00.000Z",
884916
auth: { status: "unknown" },
917+
message: "Checking ACP authentication, models, and commands in the background...",
885918
models: [{ slug: "default", name: "Default", isCustom: false, capabilities: null }],
886919
} satisfies ServerProvider;
920+
// A saved sign-in confirmation marks the readiness snapshot authenticated
921+
// before discovery has run.
922+
const confirmedCheckingProvider = {
923+
...checkingProvider,
924+
auth: { status: "authenticated" },
925+
} satisfies ServerProvider;
887926
const failedProbeProvider = {
888927
...checkingProvider,
889928
status: "warning",
929+
message: "ACP discovery failed.",
890930
} satisfies ServerProvider;
891931

892932
assert.deepStrictEqual(
@@ -896,6 +936,13 @@ it.layer(
896936
{ slug: "gpt-5.6-sol", name: "GPT-5.6-Sol", isCustom: false, capabilities: null },
897937
],
898938
);
939+
assert.deepStrictEqual(
940+
ProviderRegistry.mergeProviderSnapshot(previousProvider, confirmedCheckingProvider).models,
941+
[
942+
{ slug: "default", name: "Default", isCustom: false, capabilities: null },
943+
{ slug: "gpt-5.6-sol", name: "GPT-5.6-Sol", isCustom: false, capabilities: null },
944+
],
945+
);
899946
assert.deepStrictEqual(
900947
ProviderRegistry.mergeProviderSnapshot(previousProvider, failedProbeProvider).models,
901948
[

‎apps/server/src/provider/ProviderRegistry.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,16 @@ const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean =>
157157

158158
if (provider.driver === ProviderDriverKind.make("acpRegistry")) {
159159
// ACP Registry discovery probes return the agent's complete inventory, so
160-
// a completed probe (ready and authenticated) replaces the model list —
161-
// otherwise agents that rename or collapse models leave stale entries
162-
// pinned forever through the snapshot cache. Readiness-only and failed
163-
// probe snapshots only know the "default" placeholder and stay partial.
160+
// a completed probe replaces the model list — otherwise agents that rename
161+
// or collapse models leave stale entries pinned forever through the
162+
// snapshot cache. Only a completed probe reports `nativeSessions`;
163+
// readiness-only and failed probe snapshots only know the "default"
164+
// placeholder and stay partial. Auth is no signal here: agents without
165+
// sign-in stay "unknown" after every probe.
164166
return !(
165167
provider.installed &&
166168
provider.status === "ready" &&
167-
provider.auth.status === "authenticated"
169+
provider.nativeSessions !== undefined
168170
);
169171
}
170172

0 commit comments

Comments
 (0)