Skip to content

Commit cbdf121

Browse files
committed
fix(reply): preserve accepted spawn empty completions
1 parent 167c062 commit cbdf121

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,51 @@ describe("runReplyAgent auto-compaction token update", () => {
453453
expect(result).toBeUndefined();
454454
});
455455

456+
it("keeps accepted child-session spawn-only completions silent", async () => {
457+
const sessionKey = "main";
458+
const sessionEntry = {
459+
sessionId: "session",
460+
updatedAt: Date.now(),
461+
totalTokens: 50_000,
462+
};
463+
runEmbeddedAgentMock.mockResolvedValue({
464+
payloads: [],
465+
acceptedSessionSpawns: [{ runId: "run-child", childSessionKey: "agent:main:child" }],
466+
meta: { agentMeta: {} },
467+
});
468+
469+
const { typing, sessionCtx, resolvedQueue, followupRun } = createBaseRun({
470+
storePath: "",
471+
sessionEntry,
472+
});
473+
474+
const result = await runReplyAgent({
475+
commandBody: "hello",
476+
followupRun,
477+
queueKey: sessionKey,
478+
resolvedQueue,
479+
shouldSteer: false,
480+
shouldFollowup: false,
481+
isActive: false,
482+
isStreaming: false,
483+
typing,
484+
sessionCtx,
485+
sessionEntry,
486+
sessionStore: { [sessionKey]: sessionEntry },
487+
sessionKey,
488+
defaultModel: "anthropic/claude-opus-4-6",
489+
agentCfgContextTokens: 200_000,
490+
resolvedVerboseLevel: "off",
491+
isNewSession: false,
492+
blockStreamingEnabled: false,
493+
resolvedBlockStreamingBreak: "message_end",
494+
shouldInjectGroupIntro: false,
495+
typingMode: "instant",
496+
});
497+
498+
expect(result).toBeUndefined();
499+
});
500+
456501
async function runBaseReplyWithAgentMeta(params: {
457502
agentMeta: Record<string, unknown>;
458503
collectDiagnostics?: boolean;

‎src/auto-reply/reply/agent-runner.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import crypto from "node:crypto";
33
import fs from "node:fs/promises";
44
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
5+
import { hasAcceptedSessionSpawn } from "../../agents/accepted-session-spawn.js";
56
import {
67
hasSessionAutoModelFallbackProvenance,
78
hasConfiguredModelFallbacks,
@@ -268,12 +269,14 @@ function hasSuccessfulSideEffectDelivery(params: {
268269
messagingToolSentMediaUrls?: string[];
269270
messagingToolSentTargets?: unknown[];
270271
didSendViaMessagingTool?: boolean;
272+
acceptedSessionSpawns?: unknown[];
271273
successfulCronAdds?: number;
272274
didSendDeterministicApprovalPrompt?: boolean;
273275
}): boolean {
274276
return (
275277
params.didSendViaMessagingTool === true ||
276278
hasSuccessfulSourceReplyDelivery(params) ||
279+
hasAcceptedSessionSpawn(params.acceptedSessionSpawns) ||
277280
(params.successfulCronAdds ?? 0) > 0 ||
278281
params.didSendDeterministicApprovalPrompt === true
279282
);
@@ -1977,6 +1980,7 @@ export async function runReplyAgent(params: {
19771980
messagingToolSentMediaUrls: runResult.messagingToolSentMediaUrls,
19781981
messagingToolSentTargets: runResult.messagingToolSentTargets,
19791982
didSendViaMessagingTool: runResult.didSendViaMessagingTool,
1983+
acceptedSessionSpawns: runResult.acceptedSessionSpawns,
19801984
successfulCronAdds: runResult.successfulCronAdds,
19811985
didSendDeterministicApprovalPrompt: runResult.didSendDeterministicApprovalPrompt,
19821986
});

‎src/auto-reply/reply/followup-runner.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4116,6 +4116,17 @@ describe("createFollowupRunner messaging delivery and dedupe", () => {
41164116
expect(onBlockReply).not.toHaveBeenCalled();
41174117
});
41184118

4119+
it("keeps accepted child-session spawn-only followup completions silent", async () => {
4120+
const { onBlockReply } = await runEmptyInteractiveCase({
4121+
agentResult: {
4122+
acceptedSessionSpawns: [{ runId: "run-child", childSessionKey: "agent:main:child" }],
4123+
},
4124+
});
4125+
4126+
expect(routeReplyMock).not.toHaveBeenCalled();
4127+
expect(onBlockReply).not.toHaveBeenCalled();
4128+
});
4129+
41194130
it("keeps cron and approval side-effect followups silent", async () => {
41204131
await runEmptyInteractiveCase({
41214132
agentResult: {

‎src/auto-reply/reply/followup-runner.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import crypto from "node:crypto";
33
import { readStringValue } from "@openclaw/normalization-core/string-coerce";
44
import { hasOutboundReplyContent } from "openclaw/plugin-sdk/reply-payload";
5+
import { hasAcceptedSessionSpawn } from "../../agents/accepted-session-spawn.js";
56
import {
67
clearAutoFallbackPrimaryProbeSelection,
78
entryMatchesAutoFallbackPrimaryProbe,
@@ -1465,6 +1466,7 @@ export function createFollowupRunner(params: {
14651466
hasNonEmptyStringArray(runResult.messagingToolSentTexts) ||
14661467
hasNonEmptyStringArray(runResult.messagingToolSentMediaUrls) ||
14671468
hasCommittedMessagingTargetDeliveryEvidence(runResult.messagingToolSentTargets) ||
1469+
hasAcceptedSessionSpawn(runResult.acceptedSessionSpawns) ||
14681470
(runResult.successfulCronAdds ?? 0) > 0 ||
14691471
runResult.didSendDeterministicApprovalPrompt === true,
14701472
allowEmptyAssistantReplyAsSilent: run.allowEmptyAssistantReplyAsSilent,

0 commit comments

Comments
 (0)