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, 16:00 UTC
fix(server): subagent hover cards show reasoning effort again (#35333)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com>
Bilal Bakr committed
Nov 14, 2026 at 13:16 UTC
298c38d7f282c97f54cab590e6a87aebc7440716
5 files changed
+158
-9
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+80
-7
@@ -17889,6 +17889,14 @@ describe("ClaudeAdapterV2 background wake turns", () => {
17889
yield* harness.awaitContinuation(1);
17890
17891
yield* Queue.shutdown(harness.sdkMessages);
17892
+ yield* harness.until(() =>
17893
+ harness.events.some(
17894
+ (event) =>
17895
+ event.type === "subagent.updated" &&
17896
+ event.subagent.nativeTaskRef?.nativeId === OUTER_TASK_ID &&
17897
+ event.subagent.status === "completed",
17898
+ ),
17899
+ );
17900
yield* yieldTicks(50);
17901
yield* harness.runtime.startTurn(
17902
makeClaudeTestTurnInput({
@@ -19043,12 +19051,36 @@ describe("ClaudeAdapterV2 background wake turns", () => {
19051
),
19052
);
19053
19046
- it.effect("records only explicit effort for nested subagents", () =>
19047
- Effect.gen(function* () {
19054
+ it.effect("records explicit effort, else the effort a subagent's transcript reports", () => {
19055
+ const UNSPECIFIED_TOOL_USE_ID = "toolu-effort-nested-unspecified";
19056
+ const firstRead = Deferred.makeUnsafe<void>();
19057
+ return Effect.gen(function* () {
19058
const OUTER_TOOL_USE_ID = "toolu-effort-outer";
19049
- const UNSPECIFIED_TOOL_USE_ID = "toolu-effort-nested-unspecified";
19059
const OVERRIDING_TOOL_USE_ID = "toolu-effort-nested-overriding";
19051
- const harness = yield* makeWakeHarness;
19060
+ const fileSystem = yield* FileSystem.FileSystem;
19061
+ const configDir = yield* fileSystem.makeTempDirectoryScoped({
19062
+ prefix: "t3-claude-effort-",
19063
+ });
19064
+ // Claude names the folder after the resolved cwd, here as if /workspace were a symlink.
19065
+ const subagentsDir = NodePath.join(
19066
+ configDir,
19067
+ "projects",
19068
+ "-private-workspace",
19069
+ WAKE_NATIVE_SESSION,
19070
+ "subagents",
19071
+ );
19072
+ yield* fileSystem.makeDirectory(subagentsDir, { recursive: true });
19073
+ const transcriptPath = NodePath.join(
19074
+ subagentsDir,
19075
+ `agent-task-${UNSPECIFIED_TOOL_USE_ID}.jsonl`,
19076
+ );
19077
+ yield* fileSystem.writeFileString(
19078
+ transcriptPath,
19079
+ `{"type":"user","uuid":"effort-line-0","message":{"role":"user","content":"Check one thing."}}\n`,
19080
+ );
19081
+ const harness = yield* makeWakeHarnessWithOptions({
19082
+ environment: { CLAUDE_CONFIG_DIR: configDir },
19083
+ });
19084
const now = yield* DateTime.now;
19085
const parentSelection = {
19086
instanceId: CLAUDE_TEST_MODEL_SELECTION.instanceId,
@@ -19118,6 +19150,22 @@ describe("ClaudeAdapterV2 background wake turns", () => {
19150
}),
19151
taskStarted(UNSPECIFIED_TOOL_USE_ID, "00000000-0000-4000-8000-000000000224"),
19152
taskStarted(OVERRIDING_TOOL_USE_ID, "00000000-0000-4000-8000-000000000225"),
19153
+ claudeSdkFrame({
19154
+ type: "system",
19155
+ subtype: "task_notification",
19156
+ task_id: `task-${UNSPECIFIED_TOOL_USE_ID}`,
19157
+ tool_use_id: UNSPECIFIED_TOOL_USE_ID,
19158
+ status: "completed",
19159
+ output_file: "/tmp/claude-replay/tasks/unspecified.output",
19160
+ summary: "OK",
19161
+ uuid: "00000000-0000-4000-8000-000000000227",
19162
+ session_id: WAKE_NATIVE_SESSION,
19163
+ }),
19164
+ makeSubagentToolResultFrame({
19165
+ parentToolUseId: OUTER_TOOL_USE_ID,
19166
+ uuid: "00000000-0000-4000-8000-000000000228",
19167
+ toolUseId: UNSPECIFIED_TOOL_USE_ID,
19168
+ }),
19169
makeResultFrame({
19170
uuid: "00000000-0000-4000-8000-000000000226",
19171
result: "Spawned the subagents.",
@@ -19125,7 +19173,27 @@ describe("ClaudeAdapterV2 background wake turns", () => {
19173
]) {
19174
yield* Queue.offer(harness.sdkMessages, frame);
19175
}
19176
+ // The settled subagent's reply lands after the first lookup, beyond one read's cap.
19177
+ yield* Deferred.await(firstRead);
19178
+ NodeFS.appendFileSync(
19179
+ transcriptPath,
19180
+ `${"x".repeat(512 * 1024 + 1)}\n{"type":"assistant","effort":"low","uuid":"effort-line-1","message":{"role":"assistant","id":"msg_effort_child","content":[{"type":"text","text":"OK"}]}}\n`,
19181
+ );
19182
+ yield* TestClock.adjust(500);
19183
yield* Queue.take(harness.terminalReceipts);
19184
+ // A run can stop reading events once its subagents settle, so the settle carries the effort.
19185
+ const settle = harness.events.find(
19186
+ (event) =>
19187
+ event.type === "subagent.updated" &&
19188
+ event.subagent.status === "completed" &&
19189
+ event.subagent.nativeTaskRef?.nativeId === `task-${UNSPECIFIED_TOOL_USE_ID}`,
19190
+ );
19191
+ assert.equal(
19192
+ settle?.type === "subagent.updated"
19193
+ ? getModelSelectionStringOptionValue(settle.subagent.modelSelection, "effort")
19194
+ : null,
19195
+ "low",
19196
+ );
19197
19198
const efforts = new Map(
19199
harness.events.flatMap((event) =>
@@ -19141,7 +19209,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
19209
);
19210
assert.deepEqual(Object.fromEntries(efforts), {
19211
[`task-${OUTER_TOOL_USE_ID}`]: "low",
19144
- [`task-${UNSPECIFIED_TOOL_USE_ID}`]: undefined,
19212
+ [`task-${UNSPECIFIED_TOOL_USE_ID}`]: "low",
19213
[`task-${OVERRIDING_TOOL_USE_ID}`]: "max",
19214
});
19215
const childEfforts = harness.events.flatMap((event) =>
@@ -19151,6 +19219,11 @@ describe("ClaudeAdapterV2 background wake turns", () => {
19219
);
19220
assert.deepEqual(childEfforts, ["low", undefined, "max"]);
19221
}).pipe(
19222
+ Effect.provideService(WorkflowAgentTranscriptReadObserver, (read) =>
19223
+ read.agentId === `task-${UNSPECIFIED_TOOL_USE_ID}`
19224
+ ? Deferred.succeed(firstRead, undefined).pipe(Effect.asVoid)
19225
+ : Effect.void,
19226
+ ),
19227
Effect.provide(
19228
Layer.mergeAll(
19229
IdAllocator.layer,
@@ -19159,8 +19232,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {
19232
NodeCrypto.layer,
19233
),
19234
),
19162
- ),
19163
- );
19235
+ );
19236
+ });
19237
19238
it.effect.each([
19239
{
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+74
-2
@@ -7503,6 +7503,63 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
7503
: new Map(current).set(nativeThreadId, { ...entry, messages });
7504
});
7505
7506
+ // Claude Code records the effort a subagent ran at only in its transcript.
7507
+ const readSubagentTranscriptEffort = Effect.fnUntraced(function* (
7508
+ context: ActiveClaudeTurnContext,
7509
+ taskId: string,
7510
+ completed: boolean,
7511
+ ) {
7512
+ const cwd = context.input.runtimePolicy.cwd;
7513
+ if (cwd === null) return undefined;
7514
+ const configured = adapterOptions.environment.CLAUDE_CONFIG_DIR?.trim();
7515
+ const configDir = configured ? path.resolve(cwd, configured) : undefined;
7516
+ const projectsDir = path.join(
7517
+ configDir ?? path.join(yield* HostProcess.HomeDirectory, ".claude"),
7518
+ "projects",
7519
+ );
7520
+ // Claude names the project folder after the resolved, possibly hashed, cwd; find the session instead.
7521
+ let found: string | undefined;
7522
+ for (const project of yield* fileSystem
7523
+ .readDirectory(projectsDir)
7524
+ .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []))) {
7525
+ const candidate = path.join(projectsDir, project, context.nativeThreadId, "subagents");
7526
+ if (
7527
+ yield* fileSystem
7528
+ .exists(path.join(candidate, `agent-${taskId}.jsonl`))
7529
+ .pipe(Effect.orElseSucceed(() => false))
7530
+ ) {
7531
+ found = candidate;
7532
+ break;
7533
+ }
7534
+ }
7535
+ if (found === undefined) return undefined;
7536
+ const transcriptDir = found;
7537
+ let metadata: WorkflowAgentMetadata = {};
7538
+ let cursor = initialWorkflowAgentTranscriptCursor;
7539
+ const read = Effect.fnUntraced(function* () {
7540
+ while (metadata.messageId === undefined) {
7541
+ const next = yield* readWorkflowAgentTranscript({
7542
+ transcriptDir,
7543
+ agentId: taskId,
7544
+ cursor,
7545
+ ...(configDir === undefined ? {} : { configDir }),
7546
+ }).pipe(Effect.option);
7547
+ if (Option.isNone(next)) return false;
7548
+ metadata = mergeWorkflowAgentMetadata(next.value.lines, metadata);
7549
+ const advanced = next.value.cursor.offset !== cursor.offset;
7550
+ cursor = next.value.cursor;
7551
+ if (!next.value.truncated || !advanced) break;
7552
+ }
7553
+ return true;
7554
+ });
7555
+ // A completed subagent can settle before its first reply is flushed; wait out the flush once.
7556
+ if ((yield* read()) && completed && metadata.messageId === undefined) {
7557
+ yield* Effect.sleep(WORKFLOW_MEMBER_TRANSCRIPT_FLUSH_MS);
7558
+ yield* read();
7559
+ }
7560
+ return metadata.effort;
7561
+ });
7562
+
7563
const updateClaudeSubagentNode = Effect.fnUntraced(function* (input: {
7564
readonly context: ActiveClaudeTurnContext;
7565
readonly taskId: string;
@@ -7606,8 +7663,23 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
7663
workflow === undefined
7664
? undefined
7665
: withWorkflowMemberThreadIds(workflow, childThreadId);
7609
- // Unstated effort stays unknown: a custom agent definition may override the owner's.
7610
- const effort = existingSubagent === undefined ? input.effort : existingSubagent.effort;
7666
+ // Unstated effort stays unknown until the transcript reports it: a custom agent definition may override the owner's.
7667
+ // Read it before the settle: a run stops consuming events once its subagents settle.
7668
+ const effort =
7669
+ existingSubagent === undefined
7670
+ ? input.effort
7671
+ : (existingSubagent.effort ??
7672
+ (lifecycleChanged &&
7673
+ input.status !== "running" &&
7674
+ existingSubagent.task.modelSelection !== undefined &&
7675
+ (input.nativeTaskType ?? existingSubagent.nativeTaskType) !==
7676
+ CLAUDE_WORKFLOW_TASK_TYPE
7677
+ ? yield* readSubagentTranscriptEffort(
7678
+ input.context,
7679
+ input.taskId,
7680
+ input.status === "completed",
7681
+ )
7682
+ : undefined));
7683
const model = input.model ?? priorTask?.model ?? null;
7684
const task = {
7685
...(priorTask ?? {
apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts
+1
@@ -1254,6 +1254,7 @@ it.effect("keeps delegated child pull-request links independent of the parent",
1254
creationSource: "mcp",
1255
});
1256
const updatedParent = yield* projections.getThreadProjection(parentThreadId);
1257
+ assert.deepEqual(updatedParent.subagents[0]!.modelSelection, modelSelection);
1258
const childThreadId = updatedParent.subagents[0]!.childThreadId!;
1259
const child = yield* projections.getThreadProjection(childThreadId);
1260
assert.isNull(child.thread.linkedPullRequest);
apps/server/src/orchestration-v2/Orchestrator.ts
+2
@@ -9313,6 +9313,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
9313
prompt: command.task,
9314
title: command.title ?? null,
9315
model: command.modelSelection.model,
9316
+ modelSelection: command.modelSelection,
9317
...(command.completionWake === undefined ? {} : { completionWake: command.completionWake }),
9318
status: "running",
9319
result: null,
@@ -9775,6 +9776,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
9776
prompt: command.task,
9777
title: command.title ?? null,
9778
model: command.modelSelection.model,
9779
+ modelSelection: command.modelSelection,
9780
...(command.completionWake === undefined ? {} : { completionWake: command.completionWake }),
9781
status: "running",
9782
result: null,
apps/server/src/orchestration-v2/RemoteDelegatedTask.test.ts
+1
@@ -217,6 +217,7 @@ it.layer(layerTest)("a delegated task in a linked environment", (it) => {
217
const [task] = projection.subagents;
218
assert.equal(task?.childThreadId, null);
219
assert.deepEqual(task?.remoteChild, remoteChild);
220
+ assert.deepEqual(task?.modelSelection, modelSelection);
221
assert.equal(task?.status, "running");
222
const item = projection.turnItems.find((candidate) => candidate.type === "subagent");
223
assert.deepEqual(item?.type === "subagent" ? item.remoteChild : undefined, remoteChild);