← Back to library

子代理结果“跑完但没回报”:建立 sessions 回收与补偿通知清单

问题/场景:`sessions_spawn` 完成后偶发未向父会话投递 announcement,导致结果“静默丢失”。前置条件:使用子代理并依赖完成回传。实施步骤:创建子任务前记录 sessionKey,完成后轮询会话历史并在缺失时手动回收结果补发。关键命令:`sessions_spawn`、`sessions_list`、`sessions_history`、`sessions_send`。验证:每个子任务都能在父会话留下可追溯完成记录。风险与边界:该问题仍 open,自动重试行为需验证。来源:Issue #22273。

GITHUBDiscovered 2026-02-21Author openclaw community
Prerequisites
  • Your workflow relies on subagent completion announcements for asynchronous tasks.
  • You can query session metadata/history and send fallback message to parent session.
Steps
  1. When spawning a subagent, immediately persist the spawned session key and expected deliver target.
  2. After expected completion window, check parent thread first; if missing, query `sessions_list` and `sessions_history` for completion evidence.
  3. If subagent has output but no announcement, send a fallback summary into parent session using `sessions_send`.
  4. Log incident IDs for later cleanup once upstream delivery fix ships.
Commands
sessions_spawn
sessions_list
sessions_history
sessions_send
Verify

No completed subagent result remains undiscovered; parent session always receives a final status update.

Caveats
  • Fallback replay can duplicate announcements once upstream retries are fixed; dedupe by sessionKey/messageId(需验证).
  • Avoid exposing full subagent transcripts in fallback messages if they contain sensitive data.
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post