Skip to content

fix(skills): return a stuck skill draft to pending after a deadline - #576

Open
WanX609 wants to merge 1 commit into
omdsh-dev:mainfrom
WanX609:fix/skill-draft-deadline
Open

WanX609 wants to merge 1 commit into
omdsh-dev:mainfrom
WanX609:fix/skill-draft-deadline

Conversation

@WanX609

@WanX609 WanX609 commented Nov 5, 2026 •

Copy link
Copy Markdown

摘要 / Summary

草案子任务挂死时,建议会永远停在 drafting:background() 只挂 AbortController,没有截止时间;writeDraft 里的 runTask 一旦不返回,catch 永远不执行,忽略/删除/重试又都被前置校验挡住,只能重启宿主才恢复。本 PR 给草案任务加 15 分钟截止:超时用可区分的 DraftDeadlineError 中止任务,并把原因写回建议,使其回到 pending 可重试。

A draft task whose subagent stops reporting never settles. background() only wires an AbortController, so the catch that returns the suggestion to pending never runs, and the page keeps showing "drafting" until the Host restarts. This gives the draft task a 15-minute deadline, aborts it with a distinguishing error, and records that reason on the suggestion.

关联 Issue 或背景 / Related Issue or Context

N/A — 没有对应 Issue。现象来自本机真实使用:一条建议停在 drafting 八分钟,期间账本零写入、没有 lastError、也没有进度;忽略/删除被拒(a draft is being written for this suggestion),最后靠重试才成功。

涉及区域 / Affected Areas

  • 子 Agent 或 Agent 工作流 / Subagent or Agent workflow
  • Host 激活、Headless 或 bundle / Host activation, Headless, or bundle
  • 运行时记忆 / Runtime Memory
  • 项目档案 / Project Documents
  • 记忆空间或 Provider / Memory Spaces or Providers
  • 设置、存储或安全 / Settings, storage, or security
  • Web UI 或对话交互 / Web UI or conversation interaction
  • CLI、RPC、命令或工具 / CLI, RPC, commands, or tools
  • 安装、更新或发布 / Installation, update, or release
  • 测试、构建或文档 / Tests, build, or documentation
  • 其他(请说明)/ Other (explain below)

PR 类型 / PR Type

  • 面向用户的功能或行为变更 / User-facing feature or behavior change
  • Bug 修复 / Bug fix
  • 增强或优化 / Enhancement or optimization
  • 兼容性适配 / Compatibility change
  • 维护或重构 / Maintenance or refactor
  • 测试或构建 / Tests or build

最新代码确认 / Latest Codebase Confirmation

  • 我已基于最新 main 分支开发,或在提交前已 rebase 或合并最新 main。 / I developed from the latest main, or rebased or merged the latest main before submitting.

同步命令 / Sync command:git fetch origin main;分支基于 0db25213d128dfeb420163de20fd41a787366c87(fork 与上游同一提交)。

AI 编码披露 / AI Coding Disclosure

  • 完全 AI 编码:全部编程改动由 AI 产出,并由贡献者接受和审查。

使用的 AI 模型 / AI model used:DeepSeek-V4.1-Flash

使用的编码 Agent 工具 / Coding Agent tool used:DeepSeek Harness(DSH)桌面端

仓库规范检查 / Repository Rules

  • 未修改 DSH 官方源码,未让 tsconfig 指向 DSH 源码 checkout,仅使用正式的 @deepseek-ai/* NPM 契约。
  • Client 与 Host 边界仍以浏览器安全的 src/host/protocol.ts 为准,没有在两侧重复定义 wire DTO。
  • 持久化格式、RPC 权限、路径或凭据处理的变更包含兼容或拒绝路径、安全分析和相应测试。本 PR 不改变持久化格式,只写回既有 status / lastError 字段,长度仍受既有裁剪约束。
  • 没有提交 token、密钥、私有记忆、未脱敏日志或生成的 lib/ 文件。
  • 用户可见文案和长期文档已同步维护中文与英文版本,命令、配置键和路径保持一致。新增错误文本沿用既有英文句式(对照 memory subagent stopped with ...),没有新增设置键、命令或路径。
  • 会改变发布制品或其元数据的 PR 已添加 changeset(.changeset/skill-draft-deadline.md)。
  • 新增和修改的代码、注释、文档、提交信息不含 emoji。

兼容性与数据安全 / Compatibility and Data Safety

默认行为不变,只影响「草案任务超过 15 分钟仍未返回」这一条路径:超时中止任务,建议回到 pending 并记录原因,不写草案、不改技能文件、不改 ledger 格式或 RPC 权限。宿主关闭时的普通 abort 不携带 DraftDeadlineError,仍走原来的错误文案,已有的取消语义(不保存已完成结果)保持不动。

Only the "task has not returned within 15 minutes" path changes: the task is aborted, the suggestion returns to pending with the reason recorded, and no draft, skill file, ledger format, or RPC authority changes. A plain Host-shutdown abort carries no DraftDeadlineError and keeps the previous message.

本地验证 / Local Validation

执行的命令 / Commands run:

# 本机到 GitHub 的连接不可用(clone TLS 失败、tarball 断流),以下命令未能执行
pnpm install --frozen-lockfile
pnpm run typecheck
pnpm exec vitest run tests/skill-evolution.spec.ts

结果摘要 / Result summary:

本地未能执行:贡献者所在网络无法克隆仓库或安装依赖,CI 为第一次完整执行,结果以 CI 为准,失败我来补。新增用例(tests/skill-evolution.spec.ts):把草案任务的 runTask 换成「只在 abort 时 reject」的 promise,用 fake timers 推进 16 分钟,断言建议回到 pending 且 lastError 为 skill draft did not finish within 15 minutes。

改动 / Changes

  • src/host/skill-evolution.ts
    • background() 增加可选 deadlineMs:到期以 DraftDeadlineError 调用 controller.abort(),并在 finally 里清定时器。
    • draft() 传 DRAFT_DEADLINE_MS(15 分钟),catch 记录 deadlineReason(signal) ?? error。
    • deadlineReason() 只认 DraftDeadlineError,宿主关闭的普通 abort 不受影响。
  • tests/skill-evolution.spec.ts:新增 1 个用例。
  • .changeset/skill-draft-deadline.md:patch。

A draft task whose subagent stops reporting never settles, so its suggestion stayed drafting and could not be dismissed, deleted or retried until the Host restarted. Abort the task after 15 minutes and record why, which puts the suggestion back to pending.
@WanX609
WanX609 force-pushed the fix/skill-draft-deadline branch from 9037d68 to 58d3972 Compare November 5, 2026 16:52

This branch has not been deployed

No deployments
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