From c3b2056575ff251c7dea0f7c96cb68458028fc94 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 18 Nov 2026 13:20:48 +0000 Subject: [PATCH 1/3] test(server): Hermes' reply after a background process exits reaches the thread Failing repro for #38599: a local Hermes Agent ACP provider ends its prompt, then streams the completion reply on the root session. Today the adapter neither shows it nor offers a continuation run. Co-Authored-By: Claude Opus 5.5 --- .../Adapters/AcpRegistryAdapterV2.test.ts | 83 ++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts index 1931b1a87b0d2..4fe91a0cbf994 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts @@ -209,7 +209,7 @@ const openClaudeReplaySession = Effect.fn("openClaudeReplaySession")(function* ( entries: ReadonlyArray, replayGate?: ProviderReplayGate, continuationEnabled = true, - agentId = "claude-acp", + agentId: string | Record = "claude-acp", ) { const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; @@ -251,7 +251,9 @@ const openClaudeReplaySession = Effect.fn("openClaudeReplaySession")(function* ( const adapterOptions = { selfInvocation: yield* resolveSelfInvocation(), instanceId, - settings: yield* decodeAcpRegistryAdapterSettings({ agentId }), + settings: yield* decodeAcpRegistryAdapterSettings( + typeof agentId === "string" ? { agentId } : agentId, + ), environment: {}, ...(continuationEnabled ? { continuationRequests } : {}), makeRuntime: (runtimeInput: Parameters[0]) => { @@ -287,7 +289,7 @@ const openClaudeReplaySession = Effect.fn("openClaudeReplaySession")(function* ( runtimePolicy, }); yield* Effect.addFinalizer(() => Effect.sync(() => replayGate?.releaseAll())); - if (continuationEnabled) { + if (continuationEnabled && agentId === "claude-acp") { assert.isDefined( runtime.hasPendingBackgroundWork, "Claude ACP v2 must report background work after foreground idle", @@ -1997,6 +1999,81 @@ describe("AcpRegistryAdapterV2", () => { }).pipe(Effect.provide(layerTest)), ); + // regression: #38599 Hermes replies on its own when a background process it started exits + it.effect("does not drop Hermes' reply after a background process finishes", () => + Effect.gen(function* () { + const gate = makeProviderReplayGate(["process-exit"]); + const sessionId = "hermes-session"; + const update = (sessionUpdate: Record) => + claudeFrames.update(sessionId, sessionUpdate); + const session = yield* openClaudeReplaySession( + [ + { + type: "expect_outbound", + frame: { kind: "request", method: "initialize", params: "" }, + }, + { + type: "emit_inbound", + frame: { + kind: "response", + method: "initialize", + result: { + protocolVersion: 1, + agentInfo: { name: "hermes-agent", version: "0.23.1" }, + agentCapabilities: { loadSession: true }, + authMethods: [], + }, + }, + }, + { + type: "expect_outbound", + frame: { kind: "request", method: "session/new", params: "" }, + }, + { + type: "emit_inbound", + frame: { kind: "response", method: "session/new", result: { sessionId } }, + }, + { + type: "expect_outbound", + frame: { kind: "request", method: "session/prompt", params: "" }, + }, + update({ + sessionUpdate: "agent_message_chunk", + content: { type: "text", text: "Started it in the background." }, + }), + { + type: "emit_inbound", + frame: { + kind: "response", + method: "session/prompt", + result: { stopReason: "end_turn" }, + }, + }, + { + ...update({ + sessionUpdate: "agent_message_chunk", + content: { type: "text", text: "The background command printed DONE" }, + }), + label: "process-exit", + }, + update({ sessionUpdate: "session_info_update", title: "after completion reply" }), + ], + gate, + true, + { source: "local", commandPath: "hermes", commandArgs: ["acp"] }, + ); + yield* session.runtime.startTurn(session.turnInput(1)); + const foreground = yield* session.until((event) => event.type === "turn.terminal"); + assert.include(JSON.stringify(foreground.at(-1)), '"status":"completed"'); + gate.release("process-exit"); + const wake = yield* session.throughMarker("after completion reply"); + assert.isTrue( + session.offers.length > 0 || JSON.stringify(wake).includes("printed DONE"), + "the completion reply is shown or opens a continuation run", + ); + }).pipe(Effect.provide(layerTest)), + ); + // Copilot flattens MCP titles and reports kind "read" for MCP calls and glob ("other" for rg); // its native tool.execution_start event carries the real identity. it.effect.each(["glob", "rg"])("keeps Copilot's MCP and %s identity", (toolName) => From 2b1fa7ae66d218c82b8d8e37f3e6454c4e915c44 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 18 Nov 2026 13:25:05 +0000 Subject: [PATCH 2/3] fix(server): Hermes Agent's reply after a background process finishes reaches the thread A local Hermes Agent ACP provider replies on its root session once a background process it started exits, after the prompt has settled. The ACP Registry adapter only enabled post-settle continuation for Copilot, so that reply was dropped. Recognise the local `hermes` command, as is done for copilot, kimi and omp, and enable it there. Fixes pingdotgg/t3code#38599 Co-Authored-By: Claude Opus 5.5 --- packages/provider-acp-registry/src/server/adapter.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/provider-acp-registry/src/server/adapter.ts b/packages/provider-acp-registry/src/server/adapter.ts index 105778db7e876..f930bea731552 100644 --- a/packages/provider-acp-registry/src/server/adapter.ts +++ b/packages/provider-acp-registry/src/server/adapter.ts @@ -211,6 +211,10 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu registryAgentId === "kimi-code" || (options.settings.source === "local" && /^kimi(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? "")); + // Hermes Agent is not in the public registry; local installs run `hermes acp`. + const isHermes = + options.settings.source === "local" && + /^hermes(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? ""); const isClaude = registryAgentId === "claude-acp" || (options.settings.source === "local" && @@ -269,6 +273,8 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu extractSubagentSessionEvent: extractClaudeSubagentSessionEvent, } : {}), + // Hermes replies on the root session when a background process it started exits. + ...(isHermes ? { enablePostSettleContinuation: true } : {}), ...(isDevin ? { clientCapabilitiesMeta: { From 3d97b6d7c7fa0c513d9c4ac58c1524d2f3b2091b Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 18 Nov 2026 13:35:26 +0000 Subject: [PATCH 3/3] fix(server): Hermes' continuation run finishes after delivering the background reply Hermes sends no prompt response for the reply it streams after a background process exits, so the continuation run that drains it has to end on the deferred-finalize debounce, as Grok's does. Enable deferFinalizeForBackgroundWork for Hermes alongside post-settle continuation, and extend the regression test to run the continuation and assert the reply and a completed terminal. Co-Authored-By: Claude Opus 5.5 --- .../Adapters/AcpRegistryAdapterV2.test.ts | 14 +++++++++----- .../provider-acp-registry/src/server/adapter.ts | 7 +++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts index 4fe91a0cbf994..7de5357aa76e8 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts @@ -20,6 +20,7 @@ import * as Fiber from "effect/Fiber"; import * as DateTime from "effect/DateTime"; import * as Queue from "effect/Queue"; import * as Stream from "effect/Stream"; +import * as TestClock from "effect/testing/TestClock"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; @@ -2066,11 +2067,14 @@ describe("AcpRegistryAdapterV2", () => { const foreground = yield* session.until((event) => event.type === "turn.terminal"); assert.include(JSON.stringify(foreground.at(-1)), '"status":"completed"'); gate.release("process-exit"); - const wake = yield* session.throughMarker("after completion reply"); - assert.isTrue( - session.offers.length > 0 || JSON.stringify(wake).includes("printed DONE"), - "the completion reply is shown or opens a continuation run", - ); + yield* Queue.take(session.offered); + yield* session.throughMarker("after completion reply"); + yield* session.offers[0]!.dispatchIfCurrent!(Effect.void); + yield* session.runtime.startTurn(session.turnInput(2, { continuation: true })); + yield* TestClock.adjust("10 seconds"); + const continuation = yield* session.until((event) => event.type === "turn.terminal"); + assert.include(JSON.stringify(continuation), "printed DONE"); + assert.include(JSON.stringify(continuation.at(-1)), '"status":"completed"'); }).pipe(Effect.provide(layerTest)), ); diff --git a/packages/provider-acp-registry/src/server/adapter.ts b/packages/provider-acp-registry/src/server/adapter.ts index f930bea731552..837d296773933 100644 --- a/packages/provider-acp-registry/src/server/adapter.ts +++ b/packages/provider-acp-registry/src/server/adapter.ts @@ -273,8 +273,11 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu extractSubagentSessionEvent: extractClaudeSubagentSessionEvent, } : {}), - // Hermes replies on the root session when a background process it started exits. - ...(isHermes ? { enablePostSettleContinuation: true } : {}), + // Hermes replies on the root session when a background process it started exits; no + // prompt response follows, so the continuation ends on the deferred-finalize debounce. + ...(isHermes + ? { enablePostSettleContinuation: true, deferFinalizeForBackgroundWork: true } + : {}), ...(isDevin ? { clientCapabilitiesMeta: {