@devries-cameron20 / t3code Mirror · read-only / commits / ec275c7a19
Fork 0

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, 04:45 UTC

fix(server): compacting a subagent thread no longer adds a task to its parent (#39455)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Noah Sigel committed Nov 19, 2026 at 17:32 UTC ec275c7a191da777a6b686433ac53994a4d32412
2 files changed +61
apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
+60
@@ -3600,6 +3600,66 @@ it.layer(Layer.merge(layerTest, ProviderContinuationRequests.layer))(
3600 }),
3601 );
3602
3603 + it.effect("tracks a user's follow-up but not the compaction sent ahead of it", () =>
3604 + Effect.gen(function* () {
3605 + const orchestrator = yield* Orchestrator.OrchestratorV2;
3606 + const now = yield* DateTime.now;
3607 + const parentThreadId = ThreadId.make("thread:followup-compact-parent");
3608 + const projectId = ProjectId.make("project:followup-compact");
3609 + const parentRunId = RunId.make("run:followup-compact-parent");
3610 + const rootNodeId = NodeId.make("node:followup-compact-parent");
3611 + yield* seedParentWithTerminalTask({
3612 + threadId: parentThreadId,
3613 + projectId,
3614 + runId: parentRunId,
3615 + rootNodeId,
3616 + taskId: NodeId.make("node:followup-compact-seed"),
3617 + deliveryState: "acknowledged",
3618 + now,
3619 + });
3620 + const child = yield* seedRestartCancelledChild({
3621 + parentThreadId,
3622 + projectId,
3623 + parentRunId,
3624 + rootNodeId,
3625 + name: "followup-compact-child",
3626 + completionWake: "always",
3627 + continuationPending: false,
3628 + runStatus: "completed",
3629 + now,
3630 + });
3631 + yield* orchestrator.recoverDelegatedTasks;
3632 + const tasksBefore = (yield* orchestrator.getThreadProjection(parentThreadId)).subagents
3633 + .length;
3634 +
3635 + const send = (name: string, text: string) =>
3636 + orchestrator.dispatch({
3637 + type: "message.dispatch",
3638 + createdBy: "user",
3639 + creationSource: "web",
3640 + commandId: CommandId.make(`command:followup-compact-${name}`),
3641 + threadId: child.childThreadId,
3642 + messageId: MessageId.make(`message:followup-compact-${name}`),
3643 + text,
3644 + attachments: [],
3645 + dispatchMode: { type: "queue_after_active" },
3646 + });
3647 + yield* send("compact", "/compact");
3648 + yield* send("ask", "Write the next packet.");
3649 +
3650 + const runs = (yield* orchestrator.getThreadProjection(child.childThreadId)).runs;
3651 + const runOf = (name: string) =>
3652 + runs.find((run) => run.userMessageId === `message:followup-compact-${name}`);
3653 + assert.isDefined(runOf("compact"));
3654 + assert.isUndefined(runOf("compact")?.delegatedTaskId);
3655 + assert.isDefined(runOf("ask")?.delegatedTaskId);
3656 + assert.equal(
3657 + (yield* orchestrator.getThreadProjection(parentThreadId)).subagents.length,
3658 + tasksBefore + 1,
3659 + );
3660 + }),
3661 + );
3662 +
3663 it.effect("settles a follow-up when its own work ends while another's still runs", () =>
3664 Effect.gen(function* () {
3665 const orchestrator = yield* Orchestrator.OrchestratorV2;
apps/server/src/orchestration-v2/Orchestrator.ts
+1
@@ -857,6 +857,7 @@ function mayStartSubagentFollowup(
857 ): boolean {
858 if (command.scheduledTaskId !== undefined || command.restartContinuationOfRunId !== undefined)
859 return false;
860 + if (isCompactionCommandMessage({ role: "user", ...command })) return false;
861 if (command.notification !== undefined)
862 return (
863 command.notification.source.kind !== "monitor" || command.notification.outcome !== "updated"