The best way to control Claude Code, Codex and more from any computer or phone
fix(acp-registry): recover configured agents without a registry cache (#37549)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 16, 2026 at 08:57 UTC
837a684fd20e0ca604cd681817ab1f32b1faa91f
4 files changed
+72
-13
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+46
@@ -1559,6 +1559,52 @@ describe("AcpRegistrySupport", () => {
1559
);
1560
});
1561
1562
+ it.effect("recovers inspection from a corrupt cache once the registry is reachable", () => {
1563
+ const agent = makeAgent({ npx: { package: "@example/acp@1.2.3" } });
1564
+ let online = false;
1565
+ let requests = 0;
1566
+ return Effect.gen(function* () {
1567
+ const fileSystem = yield* FileSystem.FileSystem;
1568
+ const cacheDir = yield* fileSystem.makeTempDirectoryScoped({
1569
+ prefix: "t3-acp-registry-offline-",
1570
+ });
1571
+ yield* fileSystem.makeDirectory(`${cacheDir}/acp-registry`, { recursive: true });
1572
+ yield* fileSystem.writeFileString(`${cacheDir}/acp-registry/registry.json`, "{not json");
1573
+ const options = { cacheDir, toolsDir: `${cacheDir}/tools`, registryUrl };
1574
+ const resolver = yield* AcpRegistrySupport.makeAcpRegistryCatalog(options);
1575
+
1576
+ const offline = yield* resolver.inspect(settings()).pipe(Effect.flip);
1577
+ expect(offline.reason).toBe("registry_unavailable");
1578
+
1579
+ online = true;
1580
+ const concurrent = yield* Effect.all(
1581
+ [resolver.inspect(settings()), resolver.inspect(settings())],
1582
+ { concurrency: "unbounded" },
1583
+ );
1584
+ expect(concurrent).toMatchObject([{ status: "ready" }, { status: "ready" }]);
1585
+ expect(requests).toBe(2);
1586
+
1587
+ const restarted = yield* AcpRegistrySupport.makeAcpRegistryCatalog(options);
1588
+ expect(yield* restarted.inspect(settings())).toMatchObject({ status: "ready" });
1589
+ expect(requests).toBe(2);
1590
+ }).pipe(
1591
+ Effect.scoped,
1592
+ Effect.provide(
1593
+ layerResolver((request) => {
1594
+ requests += 1;
1595
+ return Effect.succeed(
1596
+ HttpClientResponse.fromWeb(
1597
+ request,
1598
+ online
1599
+ ? new Response(makeRegistry(agent))
1600
+ : new Response("unavailable", { status: 503 }),
1601
+ ),
1602
+ );
1603
+ }),
1604
+ ),
1605
+ );
1606
+ });
1607
+
1608
it.effect("uses the effective provider environment for inspection and resolution", () => {
1609
const agent = makeAgent({ npx: { package: "@example/acp@1.2.3" } });
1610
return Effect.gen(function* () {
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+3
-12
@@ -903,25 +903,16 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
903
return yield* refreshRegistry();
904
});
905
906
- const loadCachedRegistry = Effect.fn("AcpRegistryCatalog.loadCachedRegistry")(function* () {
906
+ const loadRegistry = Effect.fn("AcpRegistryCatalog.loadRegistry")(function* () {
907
const current = yield* Ref.get(registryRef);
908
if (current !== undefined) return current;
909
910
const cached = yield* readCachedRegistry;
911
- if (Option.isNone(cached)) {
912
- return yield* new AcpRegistryError({
913
- reason: "registry_unavailable",
914
- detail: "No valid cached ACP Registry index is available.",
915
- });
916
- }
911
+ if (Option.isNone(cached)) return yield* refreshRegistry();
912
yield* Ref.set(registryRef, cached.value);
913
return cached.value;
914
});
915
921
- const loadRegistry = Effect.fn("AcpRegistryCatalog.loadRegistry")(function* () {
922
- return yield* loadCachedRegistry().pipe(Effect.catch(() => refreshRegistry()));
923
- });
924
-
916
const runCommand = Effect.fn("AcpRegistryCatalog.runCommand")(function* (
917
command: string,
918
args: ReadonlyArray<string>,
@@ -1760,7 +1751,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1751
}
1752
const agentId = settings.agentId.trim();
1753
if (agentId.length === 0) return { status: "unconfigured" } as const;
1763
- const registry = yield* loadCachedRegistry();
1754
+ const registry = yield* loadRegistry();
1755
const agent = registry.agents.find((candidate) => candidate.id === agentId);
1756
if (agent === undefined) return { status: "not_found", agentId } as const;
1757
const documentationUrl = agent.website ?? agent.repository;
packages/provider-acp-registry/src/server/driver.test.ts
+21
@@ -883,6 +883,27 @@ const driverLayer = TestProviderHost.layer({ runBackgroundWork: false }).pipe(
883
);
884
885
it.layer(driverLayer, { excludeTestServices: true })("AcpRegistryDriver", (it) => {
886
+ it.effect("creates without inspecting the agent, which may fetch the registry", () =>
887
+ Effect.gen(function* () {
888
+ const instance = yield* AcpRegistryDriver.create({
889
+ instanceId: identity.instanceId,
890
+ displayName: identity.displayName,
891
+ enabled: true,
892
+ environment: [],
893
+ config: decodeSettings({ agentId: "test-agent" }),
894
+ }).pipe(
895
+ Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, {
896
+ ...catalogWithInspection({ status: "unconfigured" }),
897
+ inspect: () => Effect.die("inspected during creation"),
898
+ }),
899
+ );
900
+ expect(yield* instance.snapshot.getSnapshot).toMatchObject({
901
+ installed: false,
902
+ message: "Checking ACP Registry agent readiness...",
903
+ });
904
+ }),
905
+ );
906
+
907
it.effect("drops cached and session-reported models when its caches are invalidated", () =>
908
Effect.gen(function* () {
909
const fileSystem = yield* FileSystem.FileSystem;
packages/provider-acp-registry/src/server/driver.ts
+2
-1
@@ -815,7 +815,8 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
815
getSettings: snapshotSettings.getSettings,
816
streamSettings: snapshotSettings.streamSettings,
817
haveSettingsChanged: haveProviderSnapshotSettingsChanged,
818
- initialSnapshot: () => checkProvider,
818
+ // Inspection may fetch the registry when its disk cache is missing; creation must not wait on that.
819
+ initialSnapshot: () => buildInitialAcpRegistrySnapshot(readinessInput),
820
checkProvider,
821
enrichSnapshot: Effect.fn("enrichSnapshot")(function ({
822
snapshot,