Skip to content

Commit 980c8f4

Browse files
t3dotggclaude
andcommitted
fix(provider-muse): record Muse subagent replays and drop the child-session path
Live Muse 1.4.4 recordings show that `view/subscribe` and `session/read` both answer sessionNotFound for an inline child session, so the child thread can only show the prompt and result. Drop the follow path. A child-thread approval could not be answered: Muse child threads have no provider session binding. Child approvals stay on the parent, as Codex and OpenCode do. A stopped or failed turn now ends its subagents and workflows in the adapter too. The orchestrator stops following them, so the thread kept listing them as background work. Adds recorded fixtures: subagent_v2 for Muse, muse_subagent_approval, and muse_subagent_interrupt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9c44119 commit 980c8f4

12 files changed

Lines changed: 432 additions & 636 deletions

File tree

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ import { messageSteeringInput } from "./message_steering/input.ts";
5858
import { assertPiMessageSteeringOutput } from "./message_steering/pi_output.ts";
5959
import { MUSE_PERMISSION_DECLINED_FILE, musePermissionInput } from "./muse_permission/input.ts";
6060
import { assertMusePermissionOutput } from "./muse_permission/output.ts";
61+
import { museSubagentApprovalInput } from "./muse_subagent_approval/input.ts";
62+
import { assertMuseSubagentApprovalOutput } from "./muse_subagent_approval/output.ts";
63+
import { museSubagentInterruptInput } from "./muse_subagent_interrupt/input.ts";
64+
import { assertMuseSubagentInterruptOutput } from "./muse_subagent_interrupt/output.ts";
6165
import { museWorkflowInput } from "./muse_workflow/input.ts";
6266
import { assertMuseWorkflowOutput } from "./muse_workflow/output.ts";
67+
import { assertMuseSubagentV2Output } from "./subagent_v2/muse_output.ts";
6368
import { assertMuseMultiTurnOutput } from "./multi_turn/muse_output.ts";
6469
import { assertMuseTurnInterruptOutput } from "./turn_interrupt/muse_output.ts";
6570
import { piCompactionInput } from "./pi_compaction/input.ts";
@@ -860,6 +865,12 @@ export const ORCHESTRATOR_REPLAY_FIXTURES: ReadonlyArray<OrchestratorReplayFixtu
860865
modelSelection: CODEX_MODEL_SELECTION,
861866
assertOutput: assertSubagentV2Output,
862867
},
868+
{
869+
driver: ProviderDriverKind.make("muse"),
870+
transcriptFile: new URL("./subagent_v2/muse_transcript.ndjson", import.meta.url),
871+
modelSelection: MUSE_MODEL_SELECTION,
872+
assertOutput: assertMuseSubagentV2Output,
873+
},
863874
],
864875
},
865876
{
@@ -1227,6 +1238,33 @@ export const ORCHESTRATOR_REPLAY_FIXTURES: ReadonlyArray<OrchestratorReplayFixtu
12271238
},
12281239
],
12291240
},
1241+
{
1242+
name: "muse_subagent_approval",
1243+
buildInput: museSubagentApprovalInput,
1244+
providers: [
1245+
{
1246+
driver: ProviderDriverKind.make("muse"),
1247+
transcriptFile: new URL("./muse_subagent_approval/muse_transcript.ndjson", import.meta.url),
1248+
modelSelection: MUSE_MODEL_SELECTION,
1249+
assertOutput: assertMuseSubagentApprovalOutput,
1250+
},
1251+
],
1252+
},
1253+
{
1254+
name: "muse_subagent_interrupt",
1255+
buildInput: museSubagentInterruptInput,
1256+
providers: [
1257+
{
1258+
driver: ProviderDriverKind.make("muse"),
1259+
transcriptFile: new URL(
1260+
"./muse_subagent_interrupt/muse_transcript.ndjson",
1261+
import.meta.url,
1262+
),
1263+
modelSelection: MUSE_MODEL_SELECTION,
1264+
assertOutput: assertMuseSubagentInterruptOutput,
1265+
},
1266+
],
1267+
},
12301268
{
12311269
name: "muse_workflow",
12321270
buildInput: museWorkflowInput,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { SUBAGENT_V2_APPROVAL_PROMPT, type OrchestratorFixtureInput } from "../shared.ts";
2+
3+
/**
4+
* A Supervised Muse thread spawns a native subagent that runs a shell command.
5+
* The subagent's approval is asked in its child thread and approved there.
6+
*/
7+
export function museSubagentApprovalInput(): OrchestratorFixtureInput {
8+
return {
9+
runtimeMode: "approval-required",
10+
steps: [
11+
{ type: "message", text: SUBAGENT_V2_APPROVAL_PROMPT },
12+
{ type: "approve_next_runtime_request" },
13+
],
14+
};
15+
}

‎apps/server/src/orchestration-v2/testkit/fixtures/muse_subagent_approval/muse_transcript.ndjson‎

Lines changed: 69 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { assert } from "@effect/vitest";
2+
import type { ProviderReplayTranscript } from "@t3tools/contracts";
3+
4+
import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
5+
import { assertSemanticProjectionIntegrity, projectionFor } from "../shared.ts";
6+
7+
/**
8+
* A native subagent's approval is asked on the parent thread, as Codex and
9+
* OpenCode ask theirs: Muse children have no provider session of their own to
10+
* answer from. The answer reaches Muse and the subagent finishes its work.
11+
*/
12+
export function assertMuseSubagentApprovalOutput(
13+
result: OrchestratorV2ScenarioResult,
14+
transcript: ProviderReplayTranscript,
15+
) {
16+
const projection = projectionFor(result, transcript.scenario);
17+
assertSemanticProjectionIntegrity(projection);
18+
assert.deepEqual(
19+
projection.runs.map((run) => run.status),
20+
["completed"],
21+
);
22+
23+
const requests = projection.runtimeRequests;
24+
assert.lengthOf(requests, 1);
25+
assert.equal(requests[0]?.kind, "command");
26+
assert.equal(requests[0]?.status, "resolved");
27+
assert.equal(requests[0]?.decision, "accept");
28+
const outbound = transcript.entries.flatMap((entry) =>
29+
entry.type === "expect_outbound" ? [entry.frame] : [],
30+
);
31+
assert.isTrue(
32+
outbound.some(
33+
(frame) =>
34+
typeof frame === "object" &&
35+
frame !== null &&
36+
Reflect.get(frame, "method") === "approval/decide",
37+
),
38+
"the answer reaches Muse",
39+
);
40+
41+
assert.lengthOf(projection.subagents, 1);
42+
const subagent = projection.subagents[0]!;
43+
assert.equal(subagent.status, "completed");
44+
assert.match(subagent.result ?? "", /^Written\.?$/u);
45+
if (subagent.childThreadId === null) throw new Error("The subagent has no child thread");
46+
const child = result.projections.get(subagent.childThreadId);
47+
if (child === undefined) throw new Error("The child thread has no projection");
48+
assert.lengthOf(child.runtimeRequests, 0);
49+
assert.deepEqual(
50+
child.messages.map((message) => [message.role, message.text]),
51+
[
52+
["user", subagent.prompt],
53+
["assistant", subagent.result],
54+
],
55+
);
56+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { OrchestratorFixtureInput } from "../shared.ts";
2+
3+
export const MUSE_SUBAGENT_INTERRUPT_PROMPT =
4+
"Spawn one subagent whose only task is to run the shell command `sleep 30` and then reply with exactly: Done. Wait for it to finish, then reply with exactly what it said.";
5+
6+
/** Stop while a Muse native subagent is still running. */
7+
export function museSubagentInterruptInput(): OrchestratorFixtureInput {
8+
return {
9+
steps: [
10+
{ type: "message", text: MUSE_SUBAGENT_INTERRUPT_PROMPT },
11+
{ type: "interrupt", targetRunIndex: 1, waitForTurnItemType: "subagent" },
12+
],
13+
};
14+
}

0 commit comments

Comments
 (0)