Skip to content

fix(tasks): 沉默跳过判为 SKIPPED + 超时拆出 TIMEOUT(补全 #41) - #46

Open
o00nmq wants to merge 1 commit into
Archeb:agenticfrom
o00nmq:pr-tasks
Open

fix(tasks): 沉默跳过判为 SKIPPED + 超时拆出 TIMEOUT(补全 #41)#46
o00nmq wants to merge 1 commit into
Archeb:agenticfrom
o00nmq:pr-tasks

Conversation

@o00nmq

@o00nmq o00nmq commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

背景

#41 给派发任务终态加了 endReasonToTaskStatusinterrupted→SKIPPEDerror→ERROR、其余→COMPLETED)以及 global-state 的启动对账 / 终态立即落盘。

但线上复查发现问题没真正解决:最近 500 条派发任务 100% 都是 COMPLETED,其中约 20%(98 条)整轮没发任何消息——这些是「想过之后决定不回复」的有意沉默(思考记录里明确写着「够了不用再接」「话题自然收尾」之类)。

根因:真正的「沉默跳过」是 end_turn + 零产出,不是 interruptedinterrupted 只在被新消息打断时才出现)。#41 只挂在 interrupted 上,所以主流的沉默跳过仍然落 COMPLETED

🙏 先为 #41 那版不完整的修复道个歉:当时把「跳过」判定挂在 endReason === "interrupted" 上是认错了信号——绝大多数主动不回复的轮次其实是正常 end_turn 收尾、只是没发消息,结果一条都没被正确标成 SKIPPED,等于没修到点子上。这个 PR 补上真正的判定。

改动

  • 新增 classifyDispatchedTaskStatus(endReason, { producedOutput, error }),在 endReasonToTaskStatus 之上叠加运行时信息:
    • 正常收尾(end_turn / max_turns)但整轮没有任何对外动作(没发消息、没贴表态)→ SKIPPED
    • error 且错误是超时 → TIMEOUT(把执行 / LLM 超时从泛 ERROR 拆出来)
    • 其余沿用 endReasonToTaskStatus
  • 表态计入「对外动作」:telegram / discordsendReactionsystem.agent_reaction_sentSentMessageCollector 累计 reactionCount(贴纸 / 媒体已走 allSent,故 sticker-only 仍 COMPLETED;telegram emoji=null 撤销表态不计)。
  • catch 路径:超时异常 → TIMEOUT(区别于用户取消的 SKIPPED 和泛 ERROR)。
  • isTimeoutError:宽口径超时判定(代码块执行超时 + LLM 调用超时)。
  • global-state 的启动对账 / 终态立即落盘沿用 fix(tasks): 对账泄漏的 dispatched-task 终态;interrupted→SKIPPED #41 实现,未改动。

测试

  • end-reason-status.test.ts:新增 classifyDispatchedTaskStatus 用例(无产出→SKIPPED、有产出→COMPLETED、超时→TIMEOUT、interrupted 让路语义)。
  • session-runner.test.tsisTimeoutError + SentMessageCollector 表态计数。
  • platform-dedup.test.ts:telegram / discord 表态事件(含 telegram emoji=null 不发事件)。

验证

已在测试机(萩原)上线并验证:Telegram 连接正常、Restarts=0、无报错;新派发任务现在会正确出现 SKIPPED / TIMEOUT

🤖 Generated with Claude Code

…RROR

之前派发任务终态实质只由 endReason 决定:本分支已把 interrupted→SKIPPED,但主流的
"想过之后决定不回复"是 end_turn + 零产出,仍被误记为 COMPLETED。live 实测最近 500 条
派发任务 100% COMPLETED,其中 ~20% 整轮没发任何消息(都是有意的沉默跳过)。

- 新增 classifyDispatchedTaskStatus:在 endReasonToTaskStatus 之上叠加运行时信息——
  正常收尾但整轮无任何对外动作(没发消息、没贴表态)→ SKIPPED;error 且为超时 → TIMEOUT。
- 表态计入"对外动作":telegram/discord sendReaction 发 system.agent_reaction_sent,
  SentMessageCollector 累计 reactionCount(贴纸/媒体已走 allSent,故 sticker-only 仍 COMPLETED);
  telegram emoji=null 为撤销表态,不计。
- catch 路径:超时异常 → TIMEOUT(区别于泛 ERROR、以及用户取消的 SKIPPED)。
- isTimeoutError:宽口径超时判定(代码块执行超时 + LLM 调用超时)。

global-state 的启动对账 / 终态立即落盘沿用本分支已有实现,未改动。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit 567f548df82911a037f01fe986da72d7d81f0e47)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant