Skip to content

[Reliability] Make long-running research jobs crash-safe and resumable #18

Closed

Description

@helsome

Background

Deep Research 是典型的长任务。真实使用中会遇到 Electron 退出、renderer reload、kernel/process crash、系统休眠、provider/network 中断等情况。如果任务状态只存在于进程内存,一次中断就会丢掉已完成的搜索、证据和模型成本;如果恢复逻辑不完整,则可能出现“永远 running”、重复工具调用、重复 citation 或重复生成报告。

需要为长任务建立 durable checkpoint / recovery contract。

Requirements

  • 为长任务定义持久化状态机,至少能区分:queued / running / interrupted / recovering / completed / failed / cancelled 或等价状态。
  • 关键阶段保存 durable checkpoint,checkpoint 不依赖 renderer / kernel 单进程内存。
  • checkpoint 至少保留恢复所需的:
    • run id / task id;
    • research plan / 当前阶段;
    • 已完成 search/retrieval/tool steps;
    • 已获得的 evidence/source refs;
    • report / synthesis 的可恢复中间状态;
    • provider/model/config identity;
    • budget usage / retry state(与 [Runtime] Add run budgets and runaway-agent safeguards #17 兼容)。
  • 应用重新启动后能发现 stale running job,并明确转换为 interrupted/recoverable,而不是永久卡住。
  • 支持用户选择:
    • resume from checkpoint;
    • restart from scratch;
    • discard interrupted run。
  • 恢复必须考虑 idempotency:已经完成且有稳定结果的步骤不能无条件再次执行,尤其不能导致重复 source、citation、report section 或有副作用的 tool action。
  • 某个 checkpoint 已损坏或版本不兼容时,应安全失败并保留可诊断信息,不允许悄悄生成错误报告。
  • 与 [Eval] Integrate Langfuse tracing and evaluation for Agent / Deep Research runs #14 trace 兼容:恢复后的 spans 能关联回原 run,且明确记录 recovery event。

Acceptance Criteria

  • renderer reload 不会丢失正在执行任务的可识别状态。
  • 应用 / kernel 被强制结束后,重启可以识别 interrupted run。
  • 至少支持一个明确的 checkpoint resume 路径,并保留已有 evidence/result。
  • 恢复后不会重复插入相同 source/citation/report section。
  • stale running state 有 reconciliation 机制。
  • 有 schema/version 机制处理 checkpoint 演进或不兼容情况。
  • unit/integration tests 覆盖状态迁移、重复恢复和损坏 checkpoint。
  • 必须执行真实故障注入 E2E:启动一次真实模型 + 实际 retrieval/search 的 Deep Research,在中途 hard-kill Electron 或 kernel process,重新启动并实际恢复/完成任务。只模拟一个 interrupted=true fixture 不算完成。
  • PR 中附 kill 点、恢复前后 run id / checkpoint、恢复后的最终报告,以及无重复 evidence/citation 的验证结果。

Non-goals

  • 不要求首版支持任意 token 级别继续生成;可以从稳定的 workflow checkpoint 恢复。
  • 不等同于简单的“聊天记录持久化”。这里关注的是可继续执行的 runtime state。

Activity

  1. nanhanq1 commented on Sep 11, 2026

    @nanhanq1
    Contributor

    认领

  2. added
    claimed
    on Sep 11, 2026
  3. github-actions commented on Sep 11, 2026

    @github-actions

    @nanhanq1 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #18。

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

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions