openclaw - 💡(How to fix) Fix Feature: Subagent AsyncGenerator 进度流暴露

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

async *submitMessage(prompt, options): AsyncGenerator<SDKMessage, void, unknown> {
  yield buildSystemInitMessage(...)
  for await (const message of query(...)) {
    yield* normalizeMessage(message)  // 10+ 种消息类型
  }
  yield { type: 'result', subtype: 'success' }
}
RAW_BUFFERClick to expand / collapse

问题

当前 OpenClaw 的 subagent 完成后,父 agent 只能通过 completion event 获取最终结果,无法实时获取中间进度(tool calls、progress messages)。这导致父 agent 在等待期间处于"盲等"状态。

来源

Claude Code 源码学习(QueryEngine.ts),发现其使用 AsyncGenerator 模式暴露查询生命周期:

async *submitMessage(prompt, options): AsyncGenerator<SDKMessage, void, unknown> {
  yield buildSystemInitMessage(...)
  for await (const message of query(...)) {
    yield* normalizeMessage(message)  // 10+ 种消息类型
  }
  yield { type: 'result', subtype: 'success' }
}

建议

让 subagent 的 query 支持 AsyncGenerator 或类似机制,使父 agent 可以订阅实时进展:

  • streamTo: "parent" 选项在现有 spawn 中已存在,但未暴露结构化进度
  • 建议增加进度回调或消息流,让父 agent 能实时获取子 agent 的 tool calls 和 progress

参考

  • Claude Code 源码:src/QueryEngine.ts submitMessage() 方法
  • 设计文档:OpenClaw workspace self-improving/design-hooks.md

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature: Subagent AsyncGenerator 进度流暴露