The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 23:30 UTC
fix(server): delete temporary ACP health probe sessions (#25397)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 11, 2026 at 05:09 UTC
a577e9404ebcaa92011c9053ba4a7ebed2a944a0
4 files changed
+69
apps/server/scripts/acp-mock-agent.ts
+4
@@ -86,6 +86,7 @@ const supportsSessionLifecycle = process.env.T3_ACP_SESSION_LIFECYCLE === "1";
86
const supportsAcpMcp = process.env.T3_ACP_MCP_ACP === "1";
87
const supportsHttpMcp = process.env.T3_ACP_MCP_HTTP === "1";
88
const supportsV2Management = process.env.T3_ACP_V2_MANAGEMENT === "1";
89
+const failDeleteSession = process.env.T3_ACP_FAIL_DELETE_SESSION === "1";
90
const advertisedAuthMethodId = process.env.T3_ACP_AUTH_METHOD_ID?.trim();
91
const initializeAuthMethodId =
92
advertisedAuthMethodId ?? (supportsSessionLifecycle ? "test" : undefined);
@@ -742,6 +743,9 @@ const program = Effect.gen(function* () {
743
yield* agent.handleDeleteSession(() =>
744
Effect.gen(function* () {
745
yield* requireAuthentication();
746
+ if (failDeleteSession) {
747
+ return yield* AcpError.AcpRequestError.internalError("delete failed");
748
+ }
749
return {};
750
}),
751
);
apps/server/src/provider/AcpRegistryProbe.test.ts
+56
@@ -9,6 +9,7 @@ import { ProviderInstanceId } from "@t3tools/contracts";
9
import { AcpRegistrySettings } from "@t3tools/provider-acp-registry/settings";
10
import { describe, expect, it } from "@effect/vitest";
11
import * as Effect from "effect/Effect";
12
+import * as FileSystem from "effect/FileSystem";
13
import * as Schema from "effect/Schema";
14
import * as EffectAcpErrors from "effect-acp/errors";
15
@@ -20,6 +21,7 @@ import {
21
logoutAcpRegistry,
22
normalizeAcpRegistryAuthMethods,
23
normalizeAcpRegistryCommands,
24
+ probeAcpRegistryConfiguration,
25
} from "@t3tools/provider-acp-registry/testing";
26
import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport";
27
@@ -379,6 +381,60 @@ describe("ACP Registry probe", () => {
381
);
382
});
383
384
+ it.live.each(["succeeds", "fails"] as const)(
385
+ "deletes its health-probe session when deletion is advertised and %s",
386
+ (deleteOutcome) =>
387
+ Effect.gen(function* () {
388
+ const fs = yield* FileSystem.FileSystem;
389
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "acp-probe-delete-" });
390
+ const requestLogPath = NodePath.join(directory, "requests.ndjson");
391
+ const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({
392
+ search: () => Effect.die("unused search"),
393
+ prepare: () => Effect.die("unused prepare"),
394
+ inspect: () => Effect.die("unused inspect"),
395
+ uninstallManagedBinary: () => Effect.die("unused uninstall"),
396
+ resolve: () =>
397
+ Effect.succeed({
398
+ agent: {
399
+ id: "mock-agent",
400
+ name: "Mock Agent",
401
+ version: "1.0.0",
402
+ description: "ACP probe cleanup test agent",
403
+ distribution: { npx: { package: "mock-agent@1.0.0" } },
404
+ },
405
+ distribution: "npx" as const,
406
+ spawn: {
407
+ command: "node",
408
+ args: [mockAgentPath],
409
+ env: {
410
+ ...process.env,
411
+ T3_ACP_V2_MANAGEMENT: "1",
412
+ T3_ACP_REQUEST_LOG_PATH: requestLogPath,
413
+ ...(deleteOutcome === "fails" ? { T3_ACP_FAIL_DELETE_SESSION: "1" } : {}),
414
+ },
415
+ },
416
+ }),
417
+ });
418
+
419
+ const result = yield* probeAcpRegistryConfiguration({
420
+ instanceId,
421
+ settings: decodeSettings({ agentId: "mock-agent" }),
422
+ cwd: process.cwd(),
423
+ environment: process.env,
424
+ }).pipe(Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog));
425
+ expect(result.probe.ready).toBe(true);
426
+ expect(result.probe.sessionManagement.canDelete).toBe(true);
427
+
428
+ const requests = (yield* fs.readFileString(requestLogPath))
429
+ .split("\n")
430
+ .filter((line) => line.length > 0)
431
+ .map((line) => JSON.parse(line));
432
+ expect(requests.filter((request) => request.method === "session/delete")).toEqual([
433
+ expect.objectContaining({ params: { sessionId: "mock-session-1" } }),
434
+ ]);
435
+ }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
436
+ );
437
+
438
it("distinguishes authentication failures from generic probe failures", () => {
439
const advertised = normalizeAcpRegistryAuthMethods([
440
{ id: "grok-login", name: "Log in with Grok" },
packages/provider-acp-registry/src/server/probe.ts
+8
@@ -45,6 +45,7 @@ const MAX_COMMAND_LINE_LENGTH = 2_048;
45
const PROBE_TIMEOUT_SECONDS = 60;
46
const PROBE_TIMEOUT = `${PROBE_TIMEOUT_SECONDS} seconds`;
47
const COMMAND_ADVERTISEMENT_GRACE = "500 millis";
48
+const PROBE_SESSION_DELETE_TIMEOUT = "5 seconds";
49
50
const boundedText = (value: string, maximumLength: number): string =>
51
value.trim().slice(0, maximumLength);
@@ -419,6 +420,13 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
420
);
421
}
422
const started = startResult.success;
423
+ // Agents that persist sessions (OpenCode) would otherwise keep one empty session per probe.
424
+ // The runtime only sends session/delete when the agent advertises it.
425
+ yield* Effect.addFinalizer(() =>
426
+ runtime
427
+ .deleteSession(started.sessionId)
428
+ .pipe(Effect.timeoutOption(PROBE_SESSION_DELETE_TIMEOUT), Effect.ignore),
429
+ );
430
yield* Deferred.await(commandsAdvertised).pipe(
431
Effect.timeoutOption(COMMAND_ADVERTISEMENT_GRACE),
432
);
packages/provider-acp-registry/src/testing.ts
+1
@@ -18,6 +18,7 @@ export {
18
logoutAcpRegistry,
19
normalizeAcpRegistryAuthMethods,
20
normalizeAcpRegistryCommands,
21
+ probeAcpRegistryConfiguration,
22
type AcpRegistryAvailableCommands,
23
type AcpRegistryLiveConfiguration,
24
} from "./server/probe.ts";