Skip to content

Commit 82908df

Browse files
shenghui kevinshenghui kevin
authored andcommitted
fix(subagent): respect ANNOUNCE_SKIP in sessions_spawn direct completion delivery
When a sub-agent spawned via sessions_spawn (mode="run") replies with exactly ANNOUNCE_SKIP, the completion message was still being delivered directly to the originating channel. The isAnnounceSkip check existed in the agent-to-agent announce path but was missing from the direct completion delivery path. This fix adds the isAnnounceSkip check before calling deliverSubagentAnnouncement, suppressing completion delivery when the sub-agent replies exactly ANNOUNCE_SKIP. Fixes #25800
1 parent 9ef0fc2 commit 82908df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/agents/subagent-announce.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { getSubagentDepthFromSessionStore } from "./subagent-depth.js";
3737
import type { SpawnSubagentMode } from "./subagent-spawn.js";
3838
import { readLatestAssistantReply } from "./tools/agent-step.js";
3939
import { sanitizeTextContent, extractAssistantText } from "./tools/sessions-helpers.js";
40+
import { isAnnounceSkip } from "./tools/sessions-send-helpers.js";
4041

4142
const FAST_TEST_MODE = process.env.OPENCLAW_TEST_FAST === "1";
4243
const FAST_TEST_RETRY_INTERVAL_MS = 8;
@@ -1141,6 +1142,11 @@ export async function runSubagentAnnounceFlow(params: {
11411142
const subagentName = resolveAgentIdFromSessionKey(params.childSessionKey);
11421143
const announceSessionId = childSessionId || "unknown";
11431144
const findings = reply || "(no output)";
1145+
1146+
// If the sub-agent replied exactly ANNOUNCE_SKIP, skip completion delivery
1147+
// but still send the internal trigger message to the requester session.
1148+
const shouldSkipCompletionDelivery = isAnnounceSkip(reply);
1149+
11441150
let completionMessage = "";
11451151
let triggerMessage = "";
11461152

@@ -1264,7 +1270,8 @@ export async function runSubagentAnnounceFlow(params: {
12641270
directOrigin,
12651271
targetRequesterSessionKey,
12661272
requesterIsSubagent,
1267-
expectsCompletionMessage: expectsCompletionMessage,
1273+
// If the sub-agent replied ANNOUNCE_SKIP, suppress completion delivery
1274+
expectsCompletionMessage: expectsCompletionMessage && !shouldSkipCompletionDelivery,
12681275
bestEffortDeliver: params.bestEffortDeliver,
12691276
completionRouteMode: completionResolution.routeMode,
12701277
spawnMode: params.spawnMode,

0 commit comments

Comments
 (0)