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

推荐订阅源

The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
月光博客
月光博客
博客园 - Franky
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
有赞技术团队
有赞技术团队
V
V2EX
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
腾讯CDC
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
Martin Fowler
Martin Fowler
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
C
Check Point Blog
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog

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(gateway): bootstrap agent sessions before send · open...
obviyus · 2026-05-13 · via Recent Commits to openclaw:main

@@ -10,6 +10,7 @@ import {

1010

isSubagentSessionKey,

1111

normalizeAgentId,

1212

resolveAgentIdFromSessionKey,

13+

toAgentStoreSessionKey,

1314

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

1415

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

1516

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

@@ -18,6 +19,7 @@ import {

1819

type GatewayMessageChannel,

1920

INTERNAL_MESSAGE_CHANNEL,

2021

} from "../../utils/message-channel.js";

22+

import { listAgentIds } from "../agent-scope.js";

2123

import { resolveNestedAgentLaneForSession } from "../lanes.js";

2224

import {

2325

type AgentWaitResult,

@@ -53,6 +55,78 @@ const SessionsSendToolSchema = Type.Object({

5355

type GatewayCaller = typeof callGateway;

5456

const SESSIONS_SEND_REPLY_HISTORY_LIMIT = 50;

555758+

function resolveConfiguredAgentMainSessionKey(params: {

59+

cfg: OpenClawConfig;

60+

agentId: string;

61+

mainKey: string;

62+

}): string | undefined {

63+

const agentId = normalizeAgentId(params.agentId);

64+

if (!listAgentIds(params.cfg).includes(agentId)) {

65+

return undefined;

66+

}

67+

return toAgentStoreSessionKey({

68+

agentId,

69+

requestKey: "main",

70+

mainKey: params.mainKey,

71+

});

72+

}

73+74+

function isConfiguredAgentMainSessionKey(params: {

75+

cfg: OpenClawConfig;

76+

sessionKey: string;

77+

mainKey: string;

78+

}): boolean {

79+

const agentId = resolveAgentIdFromSessionKey(params.sessionKey);

80+

return (

81+

params.sessionKey ===

82+

resolveConfiguredAgentMainSessionKey({

83+

cfg: params.cfg,

84+

agentId,

85+

mainKey: params.mainKey,

86+

})

87+

);

88+

}

89+90+

async function ensureConfiguredAgentMainSession(params: {

91+

cfg: OpenClawConfig;

92+

callGateway: GatewayCaller;

93+

sessionKey: string;

94+

mainKey: string;

95+

}): Promise<{ ok: true } | { ok: false; error: string }> {

96+

if (

97+

!isConfiguredAgentMainSessionKey({

98+

cfg: params.cfg,

99+

sessionKey: params.sessionKey,

100+

mainKey: params.mainKey,

101+

})

102+

) {

103+

return { ok: true };

104+

}

105+106+

try {

107+

await params.callGateway({

108+

method: "sessions.resolve",

109+

params: { key: params.sessionKey },

110+

timeoutMs: 10_000,

111+

});

112+

return { ok: true };

113+

} catch {

114+

try {

115+

await params.callGateway({

116+

method: "sessions.create",

117+

params: {

118+

key: params.sessionKey,

119+

agentId: resolveAgentIdFromSessionKey(params.sessionKey),

120+

},

121+

timeoutMs: 10_000,

122+

});

123+

return { ok: true };

124+

} catch (err) {

125+

return { ok: false, error: formatErrorMessage(err) };

126+

}

127+

}

128+

}

129+56130

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

5713158132

function isRequesterParentOfNativeSubagentSession(params: {

@@ -145,6 +219,21 @@ export function createSessionsSendTool(opts?: {

145219

}

146220147221

let sessionKey = sessionKeyParam;

222+

if (!sessionKey && !labelParam && labelAgentIdParam) {

223+

const agentMainKey = resolveConfiguredAgentMainSessionKey({

224+

cfg,

225+

agentId: labelAgentIdParam,

226+

mainKey,

227+

});

228+

if (!agentMainKey) {

229+

return jsonResult({

230+

runId: crypto.randomUUID(),

231+

status: "error",

232+

error: `agent not found: ${labelAgentIdParam}`,

233+

});

234+

}

235+

sessionKey = agentMainKey;

236+

}

148237

if (!sessionKey && labelParam) {

149238

const requesterAgentId = resolveAgentIdFromSessionKey(effectiveRequesterKey);

150239

const requestedAgentId = labelAgentIdParam

@@ -294,6 +383,21 @@ export function createSessionsSendTool(opts?: {

294383

});

295384

}

296385386+

const ensuredSession = await ensureConfiguredAgentMainSession({

387+

cfg,

388+

callGateway: gatewayCall,

389+

sessionKey: resolvedKey,

390+

mainKey,

391+

});

392+

if (!ensuredSession.ok) {

393+

return jsonResult({

394+

runId: crypto.randomUUID(),

395+

status: "error",

396+

error: ensuredSession.error,

397+

sessionKey: displayKey,

398+

});

399+

}

400+297401

// Capture the pre-run assistant snapshot before starting the nested run.

298402

// Fast in-process test doubles and short-circuit agent paths can finish

299403

// before we reach the post-run read, which would otherwise make the new