惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
有赞技术团队
有赞技术团队
罗磊的独立博客
博客园 - 叶小钗
Jina AI
Jina AI
博客园 - 司徒正美
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
量子位
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 聂微东
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
小众软件
小众软件
宝玉的分享
宝玉的分享

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(subagents): avoid duplicate parent send replies · ope...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -2,10 +2,15 @@ import crypto from "node:crypto";

22

import { Type } from "typebox";

33

import { isRequesterParentOfBackgroundAcpSession } from "../../acp/session-interaction-mode.js";

44

import { parseSessionThreadInfoFast } from "../../config/sessions/thread-info.js";

5+

import type { SessionEntry } from "../../config/sessions/types.js";

56

import type { OpenClawConfig } from "../../config/types.openclaw.js";

67

import { callGateway } from "../../gateway/call.js";

78

import { formatErrorMessage } from "../../infra/errors.js";

8-

import { normalizeAgentId, resolveAgentIdFromSessionKey } from "../../routing/session-key.js";

9+

import {

10+

isSubagentSessionKey,

11+

normalizeAgentId,

12+

resolveAgentIdFromSessionKey,

13+

} from "../../routing/session-key.js";

914

import { annotateInterSessionPromptText } from "../../sessions/input-provenance.js";

1015

import { SESSION_LABEL_MAX_LENGTH } from "../../sessions/session-label.js";

1116

import { normalizeOptionalString } from "../../shared/string-coerce.js";

@@ -47,6 +52,25 @@ const SessionsSendToolSchema = Type.Object({

4752

type GatewayCaller = typeof callGateway;

4853

const SESSIONS_SEND_REPLY_HISTORY_LIMIT = 50;

495455+

type SessionsSendRouteEntry = Pick<SessionEntry, "acp" | "parentSessionKey" | "spawnedBy">;

56+57+

function isRequesterParentOfNativeSubagentSession(params: {

58+

entry: SessionsSendRouteEntry | null | undefined;

59+

requesterSessionKey: string | null | undefined;

60+

targetSessionKey: string;

61+

}): boolean {

62+

if (!params.entry || params.entry.acp || !isSubagentSessionKey(params.targetSessionKey)) {

63+

return false;

64+

}

65+

const requester = normalizeOptionalString(params.requesterSessionKey);

66+

if (!requester) {

67+

return false;

68+

}

69+

const spawnedBy = normalizeOptionalString(params.entry.spawnedBy);

70+

const parentSessionKey = normalizeOptionalString(params.entry.parentSessionKey);

71+

return requester === spawnedBy || requester === parentSessionKey;

72+

}

73+5074

async function startAgentRun(params: {

5175

callGateway: GatewayCaller;

5276

runId: string;

@@ -304,24 +328,34 @@ export function createSessionsSendTool(opts?: {

304328

const maxPingPongTurns = resolvePingPongTurns(cfg);

305329306330

// Skip the A2A ping-pong + announce flow when the current caller is the

307-

// parent of a parent-owned background ACP subagent it spawned itself.

308-

// Such sessions already report their results back to the parent through

309-

// the `[Internal task completion event]` announcement path, and treating

310-

// them as a peer agent causes the parent to be woken with the child's

311-

// reply, generate a user-facing response, and have that response

312-

// forwarded back to the child as a new message — producing a

313-

// ping-pong loop between parent and ACP child (bounded by

314-

// maxPingPongTurns, but user-visible as a runaway conversation).

331+

// parent of a parent-owned child session it spawned itself and another

332+

// parent-visible result path already exists.

333+

//

334+

// ACP background sessions report through the internal task completion

335+

// path. Waited native subagent sends return the child reply inline. In

336+

// both cases treating the child as a peer agent wakes the parent with

337+

// the child's reply, can generate another user-facing response, and can

338+

// forward that response back to the child as a new message — producing a

339+

// ping-pong loop (bounded by maxPingPongTurns, but visible as duplicate

340+

// conversation output).

315341

//

316342

// The skip is gated on requester ownership, not just target type: an

317343

// unrelated sender that can see the same target (e.g. under

318344

// `tools.sessions.visibility=all`) must still go through the normal A2A

319345

// path so it actually receives a follow-up delivery.

320346

const targetSessionEntry = loadSessionEntryByKey(resolvedKey);

321-

const skipA2AFlow = isRequesterParentOfBackgroundAcpSession(

347+

const skipAcpA2AFlow = isRequesterParentOfBackgroundAcpSession(

322348

targetSessionEntry,

323349

effectiveRequesterKey,

324350

);

351+

const skipNativeParentA2AFlow =

352+

timeoutSeconds !== 0 &&

353+

isRequesterParentOfNativeSubagentSession({

354+

entry: targetSessionEntry,

355+

requesterSessionKey: effectiveRequesterKey,

356+

targetSessionKey: resolvedKey,

357+

});

358+

const skipA2AFlow = skipAcpA2AFlow || skipNativeParentA2AFlow;

325359

// When the A2A flow is skipped, no follow-up announcement will fire and

326360

// the reply (when present) is returned inline via the `reply` field.

327361

// Reflect that in the metadata so the parent LLM does not wait for a