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

推荐订阅源

博客园_首页
IT之家
IT之家
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
H
Help Net Security
V
V2EX
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
博客园 - 叶小钗
J
Java Code Geeks
博客园 - 【当耐特】
月光博客
月光博客
爱范儿
爱范儿
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件

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
Harden final delivery routing refresh (#83835) · openclaw...
joshavant · 2026-05-19 · via Recent Commits to openclaw:main

@@ -338,6 +338,7 @@ export async function deliverAgentCommandResult(params: {

338338

opts: AgentCommandOpts;

339339

outboundSession: OutboundSessionContext | undefined;

340340

sessionEntry: SessionEntry | undefined;

341+

resolveFreshSessionEntryForDelivery?: () => Promise<SessionEntry | undefined>;

341342

result: RunResult;

342343

payloads: RunResult["payloads"];

343344

}): Promise<AgentCommandDeliveryResult> {

@@ -349,76 +350,144 @@ export async function deliverAgentCommandResult(params: {

349350

const turnSourceTo = opts.runContext?.currentChannelId ?? opts.to;

350351

const turnSourceAccountId = opts.runContext?.accountId ?? opts.accountId;

351352

const turnSourceThreadId = opts.runContext?.currentThreadTs ?? opts.threadId;

352-

const deliveryPlan = resolveAgentDeliveryPlan({

353-

sessionEntry,

354-

requestedChannel: opts.replyChannel ?? opts.channel,

355-

explicitTo: opts.replyTo ?? opts.to,

356-

explicitThreadId: opts.threadId,

357-

accountId: opts.replyAccountId ?? opts.accountId,

358-

wantsDelivery: deliver,

359-

turnSourceChannel,

360-

turnSourceTo,

361-

turnSourceAccountId,

362-

turnSourceThreadId,

363-

});

364-

let deliveryChannel = deliveryPlan.resolvedChannel;

365353

const explicitChannelHint = (opts.replyChannel ?? opts.channel)?.trim();

366-

if (deliver && isInternalMessageChannel(deliveryChannel) && !explicitChannelHint) {

367-

try {

368-

const selection = await resolveMessageChannelSelection({ cfg });

369-

deliveryChannel = selection.channel;

370-

} catch {

371-

// Keep the internal channel marker; error handling below reports the failure.

354+

const resolveDeliveryRouting = async (candidateSessionEntry: SessionEntry | undefined) => {

355+

const deliveryPlan = resolveAgentDeliveryPlan({

356+

sessionEntry: candidateSessionEntry,

357+

requestedChannel: opts.replyChannel ?? opts.channel,

358+

explicitTo: opts.replyTo ?? opts.to,

359+

explicitThreadId: opts.threadId,

360+

accountId: opts.replyAccountId ?? opts.accountId,

361+

wantsDelivery: deliver,

362+

turnSourceChannel,

363+

turnSourceTo,

364+

turnSourceAccountId,

365+

turnSourceThreadId,

366+

});

367+

let deliveryChannel = deliveryPlan.resolvedChannel;

368+

if (deliver && isInternalMessageChannel(deliveryChannel) && !explicitChannelHint) {

369+

try {

370+

const selection = await resolveMessageChannelSelection({ cfg });

371+

deliveryChannel = selection.channel;

372+

} catch {

373+

// Keep the internal channel marker; error handling below reports the failure.

374+

}

372375

}

373-

}

374-

const effectiveDeliveryPlan =

375-

deliveryChannel === deliveryPlan.resolvedChannel

376-

? deliveryPlan

377-

: {

378-

...deliveryPlan,

379-

resolvedChannel: deliveryChannel,

380-

};

381-

// Channel docking: delivery channels are resolved via plugin registry.

382-

const deliveryPlugin =

383-

deliver && !isInternalMessageChannel(deliveryChannel)

384-

? getChannelPlugin(normalizeChannelId(deliveryChannel) ?? deliveryChannel)

385-

: undefined;

386-387-

const isDeliveryChannelKnown =

388-

isInternalMessageChannel(deliveryChannel) || Boolean(deliveryPlugin);

376+

const effectiveDeliveryPlan =

377+

deliveryChannel === deliveryPlan.resolvedChannel

378+

? deliveryPlan

379+

: {

380+

...deliveryPlan,

381+

resolvedChannel: deliveryChannel,

382+

};

383+

// Channel docking: delivery channels are resolved via plugin registry.

384+

const deliveryPlugin =

385+

deliver && !isInternalMessageChannel(deliveryChannel)

386+

? getChannelPlugin(normalizeChannelId(deliveryChannel) ?? deliveryChannel)

387+

: undefined;

388+

const isDeliveryChannelKnown =

389+

isInternalMessageChannel(deliveryChannel) || Boolean(deliveryPlugin);

390+

const targetMode =

391+

opts.deliveryTargetMode ??

392+

effectiveDeliveryPlan.deliveryTargetMode ??

393+

(opts.to ? "explicit" : "implicit");

394+

const resolvedAccountId = effectiveDeliveryPlan.resolvedAccountId;

395+

const resolved =

396+

deliver && isDeliveryChannelKnown && deliveryChannel

397+

? resolveAgentOutboundTarget({

398+

cfg,

399+

plan: effectiveDeliveryPlan,

400+

targetMode,

401+

validateExplicitTarget: true,

402+

})

403+

: {

404+

resolvedTarget: null,

405+

resolvedTo: effectiveDeliveryPlan.resolvedTo,

406+

targetMode,

407+

};

408+

const resolvedThreadId = deliveryPlan.resolvedThreadId ?? opts.threadId;

409+

const replyTransport =

410+

deliveryPlugin?.threading?.resolveReplyTransport?.({

411+

cfg,

412+

accountId: resolvedAccountId,

413+

threadId: resolvedThreadId,

414+

}) ?? null;

415+

return {

416+

deliveryPlan,

417+

deliveryChannel,

418+

effectiveDeliveryPlan,

419+

deliveryPlugin,

420+

isDeliveryChannelKnown,

421+

targetMode,

422+

resolvedAccountId,

423+

resolved,

424+

resolvedTarget: resolved.resolvedTarget,

425+

deliveryTarget: resolved.resolvedTo,

426+

resolvedThreadId,

427+

resolvedReplyToId: replyTransport?.replyToId ?? undefined,

428+

resolvedThreadTarget:

429+

replyTransport && Object.hasOwn(replyTransport, "threadId")

430+

? (replyTransport.threadId ?? null)

431+

: (resolvedThreadId ?? null),

432+

};

433+

};

434+

const deliveryRoutingFailureReason = (

435+

route: Awaited<ReturnType<typeof resolveDeliveryRouting>>,

436+

): string | undefined => {

437+

if (!deliver) {

438+

return undefined;

439+

}

440+

if (isInternalMessageChannel(route.deliveryChannel)) {

441+

return "channel_resolved_to_internal";

442+

}

443+

if (!route.isDeliveryChannelKnown) {

444+

return "unknown_channel";

445+

}

446+

if (route.resolvedTarget && !route.resolvedTarget.ok) {

447+

return "invalid_delivery_target";

448+

}

449+

if (!route.deliveryTarget) {

450+

return "no_delivery_target";

451+

}

452+

return undefined;

453+

};

454+

const isRetryableFreshSessionRoutingFailure = (

455+

route: Awaited<ReturnType<typeof resolveDeliveryRouting>>,

456+

): boolean => {

457+

const reason = deliveryRoutingFailureReason(route);

458+

if (!reason) {

459+

return false;

460+

}

461+

if (reason === "unknown_channel") {

462+

return false;

463+

}

464+

return true;

465+

};

389466390-

const targetMode =

391-

opts.deliveryTargetMode ??

392-

effectiveDeliveryPlan.deliveryTargetMode ??

393-

(opts.to ? "explicit" : "implicit");

394-

const resolvedAccountId = effectiveDeliveryPlan.resolvedAccountId;

395-

const resolved =

396-

deliver && isDeliveryChannelKnown && deliveryChannel

397-

? resolveAgentOutboundTarget({

398-

cfg,

399-

plan: effectiveDeliveryPlan,

400-

targetMode,

401-

validateExplicitTarget: true,

402-

})

403-

: {

404-

resolvedTarget: null,

405-

resolvedTo: effectiveDeliveryPlan.resolvedTo,

406-

targetMode,

407-

};

408-

const resolvedTarget = resolved.resolvedTarget;

409-

const deliveryTarget = resolved.resolvedTo;

410-

const resolvedThreadId = deliveryPlan.resolvedThreadId ?? opts.threadId;

411-

const replyTransport =

412-

deliveryPlugin?.threading?.resolveReplyTransport?.({

413-

cfg,

414-

accountId: resolvedAccountId,

415-

threadId: resolvedThreadId,

416-

}) ?? null;

417-

const resolvedReplyToId = replyTransport?.replyToId ?? undefined;

418-

const resolvedThreadTarget =

419-

replyTransport && Object.hasOwn(replyTransport, "threadId")

420-

? (replyTransport.threadId ?? null)

421-

: (resolvedThreadId ?? null);

467+

let deliveryRouting = await resolveDeliveryRouting(sessionEntry);

468+

if (isRetryableFreshSessionRoutingFailure(deliveryRouting)) {

469+

const freshSessionEntry = await params.resolveFreshSessionEntryForDelivery?.();

470+

if (freshSessionEntry && freshSessionEntry !== sessionEntry) {

471+

const freshRouting = await resolveDeliveryRouting(freshSessionEntry);

472+

if (!deliveryRoutingFailureReason(freshRouting)) {

473+

if (!opts.json) {

474+

runtime.log(

475+

`[delivery] refreshed session routing before final delivery (session=${effectiveSessionKey ?? "unknown"} channel=${freshRouting.deliveryChannel})`,

476+

);

477+

}

478+

deliveryRouting = freshRouting;

479+

}

480+

}

481+

}

482+

const {

483+

deliveryChannel,

484+

isDeliveryChannelKnown,

485+

resolvedAccountId,

486+

resolvedTarget,

487+

deliveryTarget,

488+

resolvedReplyToId,

489+

resolvedThreadTarget,

490+

} = deliveryRouting;

422491423492

let deliveryLoggedError = false;

424493

const logDeliveryError = (err: unknown) => {