Skip to content

Commit fb8e26d

Browse files
author
Amartuvshin Surenjav
committed
fix(acp-registry): bound probe session cleanup so a silent agent cannot hang the probe
1 parent 98d6134 commit fb8e26d

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const promptDelayMs = Number(process.env.T3_ACP_PROMPT_DELAY_MS ?? "0");
6060
const supportsSessionLifecycle = process.env.T3_ACP_SESSION_LIFECYCLE === "1";
6161
const supportsAcpMcp = process.env.T3_ACP_MCP_ACP === "1";
6262
const supportsV2Management = process.env.T3_ACP_V2_MANAGEMENT === "1";
63+
const hangDeleteSession = process.env.T3_ACP_HANG_DELETE_SESSION === "1";
6364
const advertisedAuthMethodId = process.env.T3_ACP_AUTH_METHOD_ID?.trim();
6465
const initializeAuthMethodId =
6566
advertisedAuthMethodId ?? (supportsSessionLifecycle ? "test" : undefined);
@@ -693,6 +694,7 @@ const program = Effect.gen(function* () {
693694
yield* agent.handleDeleteSession(() =>
694695
Effect.gen(function* () {
695696
yield* requireAuthentication();
697+
if (hangDeleteSession) return yield* Effect.never;
696698
return {};
697699
}),
698700
);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,12 @@ describe("ACP Registry probe", () => {
432432
],
433433
},
434434
{ agentId: "mock-agent", command: undefined, reply: claudeUsage, windows: undefined },
435-
];
435+
].flatMap((testCase) => [
436+
{ ...testCase, hangDelete: false },
437+
...(testCase.agentId === "claude-acp" ? [{ ...testCase, hangDelete: true }] : []),
438+
]);
436439

437-
return Effect.forEach(cases, ({ agentId, command, reply, windows }) =>
440+
return Effect.forEach(cases, ({ agentId, command, reply, windows, hangDelete }) =>
438441
Effect.gen(function* () {
439442
const requestLogPath = NodePath.join(
440443
NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "acp-usage-")),
@@ -463,6 +466,7 @@ describe("ACP Registry probe", () => {
463466
T3_ACP_V2_MANAGEMENT: "1",
464467
T3_ACP_PROMPT_RESPONSE_TEXT: reply,
465468
T3_ACP_REQUEST_LOG_PATH: requestLogPath,
469+
...(hangDelete ? { T3_ACP_HANG_DELETE_SESSION: "1" } : {}),
466470
},
467471
},
468472
}),

‎packages/provider-acp-registry/src/server/probe.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const PROBE_TIMEOUT_SECONDS = 60;
5050
const PROBE_TIMEOUT = `${PROBE_TIMEOUT_SECONDS} seconds`;
5151
const COMMAND_ADVERTISEMENT_GRACE = "500 millis";
5252
const USAGE_COMMAND_TIMEOUT = "10 seconds";
53+
const DELETE_SESSION_TIMEOUT = "2 seconds";
5354

5455
const boundedText = (value: string, maximumLength: number): string =>
5556
value.trim().slice(0, maximumLength);
@@ -444,7 +445,13 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
444445
Effect.ensuring(
445446
started.initializeResult.agentCapabilities?.sessionCapabilities?.delete == null
446447
? Effect.void
447-
: Effect.ignore(runtime.deleteSession(started.sessionId)),
448+
: runtime
449+
.deleteSession(started.sessionId)
450+
.pipe(
451+
Effect.interruptible,
452+
Effect.timeoutOption(DELETE_SESSION_TIMEOUT),
453+
Effect.ignore,
454+
),
448455
),
449456
Effect.timeoutOption(USAGE_COMMAND_TIMEOUT),
450457
Effect.map(Option.getOrUndefined),

0 commit comments

Comments
 (0)