Skip to content

[Bug] Cron/scheduled task sessions lost real-time streaming in v0.5.x (ACP runtime regression) #1211

Description

@ditingdapeng

现象

在 v0.5.2 中,定时任务(cron job)执行时,用户无法像 v0.4.x 一样实时看到思考过程和流式输出。表现为:

  • 定时任务触发后,对应 session 没有实时内容更新
  • 任务完成后,结果内容一次性出现(而非逐步流式呈现)
  • 无法在执行过程中继续对话或观察中间状态

期望行为

与 v0.4.x 一致:定时任务运行时,切到对应 cron session 能实时看到 agent 的思考和工具调用过程。

根因分析

v0.4.x(legacy runtime)

src/stores/chat.ts 的 runtime event handler 使用 sessionKeysAreEquivalent() 将 run-scoped cron key(agent:<id>:cron:<jobId>:run:<sessionId>)桥接到 UI 跟踪的 base cron key(agent:<id>:cron:<jobId>)。这使得 cron 运行期间的所有 streaming events 实时渲染到用户正在查看的 session 中。

相关代码:

  • src/stores/chat.ts:4617 — "Cron runtime/chat events arrive under the run-scoped key ... treat those as the same session via equivalence"
  • src/stores/chat.ts:5066 — "Cron runs stream under the run-scoped session key while the UI tracks the base cron key; equivalence binds those run-scoped events to the session the user is viewing so the live graph/Thinking state renders in realtime"

v0.5.x(ACP-native runtime)

src/stores/acp-chat-session.ts 完全没有等价的 cron event 桥接逻辑。它只在 session 加载时通过 fetchCronSessionHistory() 一次性拉取已完成的历史消息,转换为 ACP notifications 注入 timeline(且仅在 timeline.itemOrder.length === 0 时才注入)。

运行中的 cron events 因为 sessionKey 不匹配(run-scoped key ≠ base key),被 ACP store 忽略。

复现步骤

  1. 创建一个 cron job(定时任务),设置为每分钟执行或手动触发
  2. 在 UI 中打开该 cron session
  3. 触发定时任务执行
  4. 观察:session 中无实时内容更新,直到任务完成后刷新

建议修复方向

acp-chat-session.ts 的 ACP session notification handler 中,加入类似旧版的 sessionKeysAreEquivalent() 桥接逻辑:当收到 run-scoped cron session key 的 notifications 时,如果 base key 与当前 activeSessionKey 匹配,则将这些 notifications 实时应用到当前 timeline。

环境

  • ClawX: v0.5.2
  • OS: macOS 15.3
  • 升级路径: v0.4.13 → v0.5.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions