@devries-cameron20 / t3code-1 / commits / 0fe71da30b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(acp-registry): each model keeps its own session options (#35458)

Julius Marminge committed Nov 12, 2026 at 10:15 UTC 0fe71da30bcc6e3ead8d5ad83c7b3f168a2322b7
5 files changed +253 -31
apps/server/src/provider/AcpRegistryProbe.test.ts
+34 -1
@@ -66,6 +66,22 @@ describe("ACP Registry probe", () => {
66 { value: "gpt-5.4", name: "Duplicate" },
67 ],
68 },
69 + {
70 + id: "effort",
71 + name: "Effort",
72 + category: "thought_level",
73 + type: "select",
74 + currentValue: "high",
75 + options: [{ value: "high", name: "High" }],
76 + },
77 + {
78 + id: "mode",
79 + name: "Mode",
80 + category: "mode",
81 + type: "select",
82 + currentValue: "ask",
83 + options: [{ value: "ask", name: "Ask" }],
84 + },
85 ],
86 },
87 modelConfigId: "model",
@@ -88,7 +104,24 @@ describe("ACP Registry probe", () => {
104 ],
105 models: [{ id: "gpt-5.4", name: "GPT-5.4", description: null }],
106 currentModelId: "gpt-5.4",
91 - configOptions: [],
107 + configOptions: [
108 + {
109 + id: "effort",
110 + label: "Effort",
111 + type: "select",
112 + options: [{ id: "high", label: "High" }],
113 + currentValue: "high",
114 + role: "reasoning",
115 + },
116 + {
117 + id: "mode",
118 + label: "Mode",
119 + type: "select",
120 + options: [{ id: "ask", label: "Ask" }],
121 + currentValue: "ask",
122 + },
123 + ],
124 + modelOptionIds: ["effort"],
125 sessionManagement: {
126 canList: true,
127 canLoad: true,
packages/contracts/src/acpRegistry.ts
+4
@@ -279,6 +279,10 @@ export const AcpRegistryProbeResult = Schema.Struct({
279 models: Schema.Array(AcpRegistryProbeModel).check(Schema.isMaxLength(256)),
280 currentModelId: Schema.NullOr(AcpRegistryProbeText),
281 configOptions: Schema.Array(ProviderOptionDescriptor).check(Schema.isMaxLength(16)),
282 + // configOptions ids that describe only the current model (ACP thought_level / model_config).
283 + modelOptionIds: Schema.optionalKey(
284 + Schema.Array(AcpRegistryProbeText).check(Schema.isMaxLength(16)),
285 + ),
286 sessionManagement: Schema.Struct({
287 canList: Schema.Boolean,
288 canLoad: Schema.Boolean,
packages/provider-acp-registry/src/server/driver.test.ts
+136 -1
@@ -1,6 +1,10 @@
1 import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2 import * as NodeServices from "@effect/platform-node/NodeServices";
3 -import { AcpRegistryOperationError, ProviderInstanceId } from "@t3tools/contracts";
3 +import {
4 + AcpRegistryOperationError,
5 + ProviderInstanceId,
6 + type ServerProvider,
7 +} from "@t3tools/contracts";
8 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
9 import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
10 import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
@@ -220,6 +224,53 @@ describe("acpRegistrySnapshotReadiness", () => {
224 capabilities: { optionDescriptors: [{ id: "effort", currentValue: "high" }] },
225 },
226 ]);
227 +
228 + // Session configOptions describe the current model only.
229 + const sharedMode = {
230 + id: "mode",
231 + label: "Mode",
232 + type: "select" as const,
233 + options: [{ id: "ask", label: "Ask" }],
234 + currentValue: "ask",
235 + };
236 + const twoModelList = [
237 + { id: "glm", name: "GLM", description: null },
238 + { id: "opus", name: "Opus", description: null },
239 + ];
240 + const afterGlm = applyAcpRegistryLiveConfiguration(
241 + provider,
242 + {
243 + models: twoModelList,
244 + currentModelId: "glm",
245 + configOptions: [...liveOptions, sharedMode],
246 + modelOptionIds: ["effort"],
247 + },
248 + [],
249 + );
250 + const twoModels = afterGlm.models;
251 + expect(twoModels.find((model) => model.slug === "glm")).toMatchObject({
252 + capabilities: { optionDescriptors: [{ id: "effort" }, { id: "mode" }] },
253 + });
254 + expect(
255 + twoModels.find((model) => model.slug === "opus")?.capabilities?.optionDescriptors ?? [],
256 + ).toEqual([sharedMode]);
257 + // A later session on another model keeps the options learned for this one.
258 + const afterOpus = applyAcpRegistryLiveConfiguration(
259 + afterGlm,
260 + {
261 + models: twoModelList,
262 + currentModelId: "opus",
263 + configOptions: [{ ...liveOptions[0]!, id: "thinking" }, sharedMode],
264 + modelOptionIds: ["thinking"],
265 + },
266 + [],
267 + ).models;
268 + expect(afterOpus.find((model) => model.slug === "glm")).toMatchObject({
269 + capabilities: { optionDescriptors: [{ id: "mode" }, { id: "effort" }] },
270 + });
271 + expect(afterOpus.find((model) => model.slug === "opus")).toMatchObject({
272 + capabilities: { optionDescriptors: [{ id: "thinking" }, { id: "mode" }] },
273 + });
274 });
275
276 it("projects discovery without claiming authentication when no login methods are advertised", () => {
@@ -554,4 +605,88 @@ it.layer(driverLayer, { excludeTestServices: true })("AcpRegistryDriver", (it) =
605 expect(Option.isSome(yield* Fiber.join(refreshed))).toBe(true);
606 }),
607 );
608 +
609 + it.effect("keeps options learned for each model across a refresh", () =>
610 + Effect.gen(function* () {
611 + const fileSystem = yield* FileSystem.FileSystem;
612 + const path = yield* Path.Path;
613 + const directory = yield* fileSystem.makeTempDirectoryScoped({ prefix: "acp-driver-" });
614 + const agentPath = path.join(directory, "agent.mjs");
615 + const modelsPath = path.join(directory, "models.json");
616 + yield* fileSystem.writeFileString(agentPath, fakeAgentSource);
617 + yield* fileSystem.writeFileString(modelsPath, JSON.stringify(["model-a", "model-b"]));
618 + const coordinator = yield* AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator;
619 +
620 + const instance = yield* AcpRegistryDriver.create({
621 + instanceId: identity.instanceId,
622 + displayName: identity.displayName,
623 + enabled: true,
624 + environment: [],
625 + config: decodeSettings({ agentId: "test-agent" }),
626 + }).pipe(
627 + Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, {
628 + ...catalogWithInspection({
629 + status: "ready",
630 + agentId: "test-agent",
631 + version: "1.0.0",
632 + distribution: "npx",
633 + }),
634 + resolve: () =>
635 + Effect.succeed({
636 + distribution: "npx" as const,
637 + spawn: { command: process.execPath, args: [agentPath, modelsPath] },
638 + }),
639 + }),
640 + );
641 + const effortBySlug = (snapshot: ServerProvider) =>
642 + snapshot.models
643 + .map(
644 + (model) =>
645 + `${model.slug}:${(model.capabilities?.optionDescriptors ?? []).map((option) => option.id).join("+")}`,
646 + )
647 + .join();
648 + const waitFor = (expected: string) =>
649 + instance.snapshot.streamChanges.pipe(
650 + Stream.filter((snapshot) => effortBySlug(snapshot) === expected),
651 + Stream.runHead,
652 + );
653 + const session = (currentModelId: string) =>
654 + normalizeAcpRegistryLiveConfiguration(
655 + [
656 + {
657 + id: "effort",
658 + name: "Effort",
659 + category: "thought_level",
660 + type: "select",
661 + currentValue: "high",
662 + options: [
663 + { value: "low", name: "Low" },
664 + { value: "high", name: "High" },
665 + ],
666 + },
667 + ],
668 + undefined,
669 + {
670 + currentModelId,
671 + availableModels: [
672 + { modelId: "model-a", name: "model-a" },
673 + { modelId: "model-b", name: "model-b" },
674 + ],
675 + },
676 + );
677 +
678 + const probed = yield* waitFor("model-a:,model-b:").pipe(Effect.forkScoped);
679 + yield* instance.snapshot.refresh;
680 + yield* Fiber.join(probed);
681 + const learned = yield* waitFor("model-a:effort,model-b:effort").pipe(Effect.forkScoped);
682 + yield* coordinator.publishLiveConfiguration(identity.instanceId, session("model-b"));
683 + yield* coordinator.publishLiveConfiguration(identity.instanceId, session("model-a"));
684 + yield* Fiber.join(learned);
685 +
686 + yield* instance.snapshot.refresh;
687 + expect(effortBySlug(yield* instance.snapshot.getSnapshot)).toBe(
688 + "model-a:effort,model-b:effort",
689 + );
690 + }),
691 + );
692 });
packages/provider-acp-registry/src/server/driver.ts
+68 -28
@@ -91,15 +91,36 @@ const makeUnsupportedTextGeneration = (): ProviderTextGeneration => {
91
92 function modelsFromDiscovery(
93 discovery:
94 - | Pick<AcpRegistryLiveConfiguration, "models" | "currentModelId" | "configOptions">
94 + | Pick<
95 + AcpRegistryLiveConfiguration,
96 + "models" | "currentModelId" | "configOptions" | "modelOptionIds"
97 + >
98 | undefined,
99 customModels: ReadonlyArray<string>,
100 + previousModels: ReadonlyArray<ServerProviderModel> = [],
101 ): ReadonlyArray<ServerProviderModel> {
102 const discovered = discovery?.models ?? [];
103 const capabilities =
104 discovery === undefined || discovery.configOptions.length === 0
105 ? EMPTY_CAPABILITIES
106 : createModelCapabilities({ optionDescriptors: discovery.configOptions });
107 + // Model-specific options describe only the session's current model; other
108 + // models keep the shared ones plus what an earlier session reported for them.
109 + const modelOptionIds = new Set(discovery?.modelOptionIds ?? []);
110 + const shared = (discovery?.configOptions ?? []).filter(
111 + (descriptor) => !modelOptionIds.has(descriptor.id),
112 + );
113 + const sharedIds = new Set(shared.map((descriptor) => descriptor.id));
114 + const capabilitiesFor = (slug: string) => {
115 + if (slug === discovery?.currentModelId) return capabilities;
116 + const own = (
117 + previousModels.find((model) => model.slug === slug)?.capabilities?.optionDescriptors ?? []
118 + ).filter((descriptor) => !sharedIds.has(descriptor.id));
119 + const optionDescriptors = [...shared, ...own];
120 + return optionDescriptors.length === 0
121 + ? EMPTY_CAPABILITIES
122 + : createModelCapabilities({ optionDescriptors });
123 + };
124 const builtInModels: ReadonlyArray<ServerProviderModel> =
125 discovered.length === 0
126 ? [
@@ -116,7 +137,7 @@ function modelsFromDiscovery(
137 name: model.name,
138 isCustom: false,
139 ...(model.id === discovery?.currentModelId ? { isDefault: true } : {}),
119 - capabilities,
140 + capabilities: capabilitiesFor(model.id),
141 }));
142 return providerModelsFromSettings(builtInModels, customModels, capabilities);
143 }
@@ -261,6 +282,7 @@ export function applyAcpRegistryLiveConfiguration(
282 provider: ServerProvider,
283 configuration: AcpRegistryLiveConfiguration,
284 customModels: ReadonlyArray<string>,
285 + previousModels: ReadonlyArray<ServerProviderModel> = provider.models,
286 ): ServerProvider {
287 const { message: _staleProbeMessage, ...snapshot } = provider;
288 // session/load may omit models (Kimi returns `{}`); keep the probed list
@@ -284,7 +306,11 @@ export function applyAcpRegistryLiveConfiguration(
306 models:
307 configuration.models.length === 0 && configuration.configOptions.length === 0
308 ? provider.models
287 - : modelsFromDiscovery(discovery, customModels),
309 + : modelsFromDiscovery(
310 + discovery,
311 + customModels,
312 + previousModels.filter((model) => !model.isCustom),
313 + ),
314 };
315 }
316
@@ -553,6 +579,23 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
579 environment,
580 processEnvironment,
581 });
582 + // Refreshes rebuild the snapshot from the probe, so per-model options
583 + // learned from earlier sessions are kept here.
584 + const learnedModels = yield* Ref.make<ReadonlyArray<ServerProviderModel>>([]);
585 + const applyLiveConfiguration = (
586 + provider: ServerProvider,
587 + configuration: AcpRegistryLiveConfiguration,
588 + ) =>
589 + Ref.modify(learnedModels, (learned) => {
590 + const next = applyAcpRegistryLiveConfiguration(
591 + provider,
592 + configuration,
593 + effectiveConfig.customModels,
594 + learned.length > 0 ? learned : provider.models,
595 + );
596 + return [next, next.models === provider.models ? learned : next.models];
597 + });
598 + const clearLearnedModels = Ref.set(learnedModels, []);
599 const withLiveRuntimeState = Effect.fn("AcpRegistryDriver.withLiveRuntimeState")(function* (
600 input: ServerProvider,
601 ) {
@@ -571,18 +614,17 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
614 configuration: runtimeCoordinator.value.getLiveConfiguration(instanceId),
615 authAction: runtimeCoordinator.value.getUrlAuthAction(instanceId),
616 }).pipe(
574 - Effect.map(({ commands, configuration, authAction }) => {
617 + Effect.flatMap(({ commands, configuration, authAction }) => {
618 const withCommands = applyAcpRegistryAvailableCommands(provider, commands);
576 - const withConfiguration = Option.match(configuration, {
577 - onNone: () => withCommands,
619 + return Option.match(configuration, {
620 + onNone: () => Effect.succeed(withCommands),
621 onSome: (liveConfiguration) =>
579 - applyAcpRegistryLiveConfiguration(
580 - withCommands,
581 - liveConfiguration,
582 - effectiveConfig.customModels,
583 - ),
584 - });
585 - return applyAcpRegistryUrlAuthAction(withConfiguration, authAction);
622 + applyLiveConfiguration(withCommands, liveConfiguration),
623 + }).pipe(
624 + Effect.map((withConfiguration) =>
625 + applyAcpRegistryUrlAuthAction(withConfiguration, authAction),
626 + ),
627 + );
628 }),
629 );
630 });
@@ -709,15 +751,8 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
751 (configuration) =>
752 liveSnapshotSemaphore.withPermit(
753 getSnapshot.pipe(
712 - Effect.flatMap((current) =>
713 - publishSnapshot(
714 - applyAcpRegistryLiveConfiguration(
715 - current,
716 - configuration,
717 - effectiveConfig.customModels,
718 - ),
719 - ),
720 - ),
754 + Effect.flatMap((current) => applyLiveConfiguration(current, configuration)),
755 + Effect.flatMap(publishSnapshot),
756 ),
757 ),
758 );
@@ -778,11 +813,13 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
813 : provided;
814 };
815
781 - const clearLiveState = Option.isSome(runtimeCoordinator)
782 - ? runtimeCoordinator.value
783 - .clearLiveConfiguration(instanceId)
784 - .pipe(Effect.andThen(runtimeCoordinator.value.clearAvailableCommands(instanceId)))
785 - : Effect.void;
816 + const clearLiveState = (
817 + Option.isSome(runtimeCoordinator)
818 + ? runtimeCoordinator.value
819 + .clearLiveConfiguration(instanceId)
820 + .pipe(Effect.andThen(runtimeCoordinator.value.clearAvailableCommands(instanceId)))
821 + : Effect.void
822 + ).pipe(Effect.andThen(clearLearnedModels));
823 const controller = yield* AcpRegistryAuth.makeAcpRegistryAuth({
824 instanceId,
825 settings: effectiveConfig,
@@ -828,7 +865,10 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
865 invalidateCaches: (Option.isSome(runtimeCoordinator)
866 ? runtimeCoordinator.value.clearLiveConfiguration(instanceId)
867 : Effect.void
831 - ).pipe(Effect.andThen(liveSnapshotSemaphore.withPermit(invalidateEnrichmentCache))),
868 + ).pipe(
869 + Effect.andThen(clearLearnedModels),
870 + Effect.andThen(liveSnapshotSemaphore.withPermit(invalidateEnrichmentCache)),
871 + ),
872 orchestrationAdapter,
873 textGeneration: makeUnsupportedTextGeneration(),
874 acpSessionManagement: {
packages/provider-acp-registry/src/server/probe.ts
+11 -1
@@ -168,6 +168,7 @@ export interface AcpRegistryLiveConfiguration {
168 readonly models: ReadonlyArray<AcpRegistryProbeModel>;
169 readonly currentModelId: string | null;
170 readonly configOptions: AcpRegistryProbeResult["configOptions"];
171 + readonly modelOptionIds?: NonNullable<AcpRegistryProbeResult["modelOptionIds"]>;
172 }
173
174 export function normalizeAcpRegistryLiveConfiguration(
@@ -195,12 +196,21 @@ export function normalizeAcpRegistryLiveConfiguration(
196 ? null
197 : (boundedOpaqueValue(currentModelId, MAX_ID_LENGTH) ?? null);
198 const models = normalizeModels(candidates, boundedCurrentModelId);
199 + const descriptors = acpProviderOptionDescriptors({ configOptions, modeState });
200 + const modelOptionIds = new Set(
201 + configOptions
202 + .filter((option) => option.category === "thought_level" || option.category === "model_config")
203 + .map((option) => option.id),
204 + );
205 return {
206 models,
207 currentModelId: models.some((model) => model.id === boundedCurrentModelId)
208 ? boundedCurrentModelId
209 : null,
203 - configOptions: acpProviderOptionDescriptors({ configOptions, modeState }),
210 + configOptions: descriptors,
211 + modelOptionIds: descriptors
212 + .filter((descriptor) => modelOptionIds.has(descriptor.id))
213 + .map((descriptor) => descriptor.id),
214 };
215 }
216