fix: guarantee manual subagent spawn sends completion message

This commit is contained in:
Peter Steinberger
2026-02-18 02:45:05 +01:00
parent 5bd95bef5a
commit e2dd827ca4
5 changed files with 35 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { resetSubagentRegistryForTests } from "../../agents/subagent-registry.js";
import type { SpawnSubagentResult } from "../../agents/subagent-spawn.js";
import type { OpenClawConfig } from "../../config/config.js";
import { resetSubagentRegistryForTests } from "../../agents/subagent-registry.js";
const hoisted = vi.hoisted(() => {
const spawnSubagentDirectMock = vi.fn();
@@ -94,6 +94,7 @@ describe("/subagents spawn command", () => {
expect(spawnParams.task).toBe("do the thing");
expect(spawnParams.agentId).toBe("beta");
expect(spawnParams.cleanup).toBe("keep");
expect(spawnParams.expectsCompletionMessage).toBe(true);
expect(spawnCtx.agentSessionKey).toBeDefined();
});

View File

@@ -1,7 +1,8 @@
import crypto from "node:crypto";
import type { SubagentRunRecord } from "../../agents/subagent-registry.js";
import type { CommandHandler } from "./commands-types.js";
import { AGENT_LANE_SUBAGENT } from "../../agents/lanes.js";
import { abortEmbeddedPiRun } from "../../agents/pi-embedded.js";
import type { SubagentRunRecord } from "../../agents/subagent-registry.js";
import {
clearSubagentRunSteerRestart,
listSubagentRunsForRequester,
@@ -35,7 +36,6 @@ import {
} from "../../shared/subagents-format.js";
import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js";
import { stopSubagentsForRequester } from "./abort.js";
import type { CommandHandler } from "./commands-types.js";
import { clearSessionQueues } from "./queue.js";
import { formatRunLabel, formatRunStatus, sortSubagentRuns } from "./subagents-utils.js";
@@ -674,7 +674,7 @@ export const handleSubagentsCommand: CommandHandler = async (params, allowTextCo
}
const result = await spawnSubagentDirect(
{ task, agentId, model, thinking, cleanup: "keep" },
{ task, agentId, model, thinking, cleanup: "keep", expectsCompletionMessage: true },
{
agentSessionKey: requesterKey,
agentChannel: params.command.channel,