Skip to content

Commit 0840bb2

Browse files
t3dotggclaude
andauthored
fix(provider-acp): Grok monitors show as monitors in background work (#24609)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 5a969c1 commit 0840bb2

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/RestartBackgroundNote.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function cancelledTurnItemWork(
5151
}
5252
case "command_execution":
5353
return {
54-
kind: "shell",
54+
kind: item.monitor === true ? "monitor" : "shell",
5555
label: compactLabel(item.input) ?? compactLabel(item.title) ?? "background command",
5656
id: item.id,
5757
};

‎apps/server/src/orchestration-v2/testkit/fixtures/grok_monitor/output.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { assert } from "@effect/vitest";
22
import type { ProviderReplayTranscript } from "@t3tools/contracts";
3+
import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
34

45
import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
6+
import { cancelledTurnItemWork } from "../../../RestartBackgroundNote.ts";
57
import {
68
assertBaseProjection,
79
assertSemanticProjectionIntegrity,
@@ -54,6 +56,20 @@ export function assertGrokMonitorOutput(
5456
assert.equal(monitorUpdates[tickUpdate]?.status, "running", `${tick} must show running`);
5557
}
5658

59+
// A persistent monitor keeps running after its run ends. Background work and
60+
// the restart note must then name it a monitor, as they do for Claude's Monitor.
61+
const runningMonitor = monitorUpdates.find((update) => update.status === "running");
62+
assert.isDefined(runningMonitor);
63+
assert.deepEqual(
64+
derivePendingBackgroundWork({
65+
latestRun: rootRun,
66+
providerThreads: [],
67+
turnItems: [runningMonitor],
68+
}).map((task) => task.kind),
69+
["monitor"],
70+
);
71+
assert.equal(cancelledTurnItemWork(runningMonitor)?.kind, "monitor");
72+
5773
const monitorCompletedAt = result.domainEvents.findIndex(
5874
(event) =>
5975
event.type === "turn-item.updated" &&

‎packages/contracts/src/orchestrationV2.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,8 @@ export const OrchestrationV2TurnItem = Schema.Union([
14771477
outputOmitted: Schema.optional(Schema.Boolean),
14781478
outputIndicatesFailure: Schema.optional(Schema.Boolean),
14791479
exitCode: Schema.optional(Schema.Int),
1480+
/** Set when the command is a monitor, so background work lists it as a monitor. */
1481+
monitor: Schema.optional(Schema.Boolean),
14801482
}),
14811483
Schema.Struct({
14821484
...OrchestrationV2TurnItemBaseFields,
@@ -2244,6 +2246,8 @@ export const OrchestrationV2TurnItemJson = Schema.Union([
22442246
outputOmitted: Schema.optional(Schema.Boolean),
22452247
outputIndicatesFailure: Schema.optional(Schema.Boolean),
22462248
exitCode: Schema.optional(Schema.Int),
2249+
/** Set when the command is a monitor, so background work lists it as a monitor. */
2250+
monitor: Schema.optional(Schema.Boolean),
22472251
}),
22482252
Schema.Struct({
22492253
...OrchestrationV2TurnItemJsonBaseFields,

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3916,6 +3916,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
39163916
? {}
39173917
: { output: textFromUnknown(rawOutput) }),
39183918
...(exitCode === undefined ? {} : { exitCode }),
3919+
...(inputVariant === "monitor" ? { monitor: true } : {}),
39193920
};
39203921
} else {
39213922
turnItem = {

‎packages/shared/src/orchestrationV2PendingBackgroundWork.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ type PendingBackgroundWorkTurnItem = {
132132
readonly nativeId: string | null;
133133
} | null;
134134
readonly input?: unknown;
135+
readonly monitor?: boolean | undefined;
135136
readonly prompt?: string | undefined;
136137
readonly childThreadId?: ThreadId | null;
137138
};
@@ -190,7 +191,7 @@ function pendingTaskFromTurnItem(
190191
...(item.childThreadId == null ? {} : { childThreadId: item.childThreadId }),
191192
};
192193
case "command_execution":
193-
return { ...named, kind: "command" };
194+
return { ...named, kind: item.monitor === true ? "monitor" : "command" };
194195
default:
195196
return { ...named, kind: "background_task" };
196197
}

0 commit comments

Comments
 (0)