Skip to content

[Bug] 守护进程模式下 state validation 失败时生成不完整的坏章节文件 #88

@welsione

Description

@welsione

Bug 描述

在守护进程模式(inkos up)下运行 write next 时,如果 Phase 2 state settlement 阶段的 StateValidator 返回空响应(LLM returned empty response),会触发以下问题:

  1. 会在 chapters/ 目录下生成一个不完整的碎片章节文件(如 "菜市场的算法" 仅 164 字)
  2. 同样会在 index.json 中写入一条完整的章节记录(包含 wordCount、auditResult 等元数据)
  3. 完整的章节文件(如 "老张的台阶" 9757 字)也会同时存在

结果:index.json 中出现两条第二章记录,且其中一条是坏数据,需要手动清理。

复现步骤

  1. 使用 inkos up 启动守护进程
  2. 运行 inkos write next --count 1 --words 3000 --context ...
  3. 在 Phase 2 state settlement 阶段模拟/遇到 LLM 返回空响应
  4. 观察 chapters/ 目录和 index.json

期望行为

state validation 失败时,应该:

  • 不要生成不完整的章节文件
  • 不要在 index.json 中写入记录
  • 应该回滚本次写作,或者至少生成一个标记为 failed 的条目

环境信息

  • InkOS 版本:最新
  • LLM Provider:anthropic(MiniMax API)
  • 模型:MiniMax-M2.7
  • INKOS_LLM_STREAM=false

日志片段

WARN  [state-validator] State validation failed: Error: LLM returned empty response
[
  {
    "chapterNumber": 2,
    "title": "菜市场的算法",
    "wordCount": 164,
    "status": "ready-for-review",
    ...
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions