SuperAPI AI 工具集

failure-classifier

智能体与模型

查看项目

更新于 10-31 13:16

技能介绍

用途

failure-classifier 用于对 T4 任务失败进行分类,使 master-planner 能够据此决定:重试、自愈、重新规划或升级。该技能是 AI 消费型参考,针对 Claude 在执行期间读取进行了优化。

失败类别

类别 名称 触发条件 建议操作
F1 transient(瞬时) 网络超时、文件锁、ECONNRESET、速率限制、不稳定的 CI 带退避重试(最多 3 次)
F2 local-logic(局部逻辑) 测试失败、类型错误、lint 错误、断言不匹配 自愈提议(Milestone E)或单次重试
F3 local-design(局部设计) 按设计无法达到故事验收标准;信号:同一测试在 2 次修复后仍失败,或输出偏离计划超过 50% 重新规划故事(重新分解 T3)
F4 story-level(故事级) 同级任务被破坏、依赖契约被违反、deviation_score ≥ 0.7 重新规划功能(重新分解 T2)
F5 architectural(架构级) 跨功能影响、任务级约束被违反 冻结并升级给用户
F6 conflict-induced(冲突引发,v3.7.0-beta.2 新增) 当失败信号上设置了 cause: conflict,或 conflict_id 非空时,分类器返回 F6,置信度 0.95,并路由到 conflict-arbiter 智能体(而非 replanner)。仲裁者应用 rules/workflow/conflict-arbitration-policy.md 中的决策表。 —

分类器输入

  • 来自 post-execute-update-node 钩子的失败事件:{tool, exit_code, stderr_tail, files_touched}
  • 活动任务节点(status、failed_attempts、replan_budget_remaining)
  • 该任务最近 10 条 history.jsonl 事件
  • 失败的测试输出(当可用时)

决策规则(确定性,自上而下评估——首个匹配生效)

  1. exit_code == 0 → 不是失败;中止分类
  2. failure.cause == "conflict" 或 failure.conflict_id 非空 → F6
  3. stderr 匹配 /ECONNRESET|ETIMEDOUT|EAI_AGAIN|429|503|rate limit/i → F1
  4. failed_attempts >= 3 且与最近 2 次尝试的 stderr_hash 相同 → F3
  5. files_touched 与同级任务的 files_touched(来自 history)相交 → F4
  6. failed_attempts == 1 且 stderr 匹配 /TypeError|SyntaxError|test failed|assertion/ → F2
  7. deviation_score(node) >= 0.7 → F4
  8. ancestor_T1.intent 被失败证据反驳 → F5
  9. 默认 → F2

输出模式

{
  "class": "F3",
  "confidence": 0.78,
  "evidence": [
    "failed_attempts=3",
    "stderr_hash matches last 2 attempts",
    "test_ref tests/auth/jwt.test.ts has been edited 4 times in revision history"
  ],
  "recommended_action": "replan_story",
  "node_id": "TASK-00101",
  "parent_node_id": "STORY-0042"
}

置信度评分

  • F1 transient:0.95(正则匹配可靠)
  • F2 local-logic:0.85(单次尝试启发式)
  • F3 local-design:0.75(多次尝试 + 相同哈希)
  • F4 story-level:0.80(文件重叠信号丰富)
  • F5 architectural:0.65(语义匹配——置信度最低)

如果置信度 < 0.6 → 输出 class: F2,操作为 single_retry_then_escalate,并呈现给用户。

该技能不做什么

  • 不调用 LLM(仅确定性——见 Q1 决策)
  • 不自行决定重试/重新规划(那是 master-planner 的职责)
  • 不修改计划树
  • 不自行在 F6 上派发仲裁——输出类别并附带 recommended_action: arbitrate 和 routes_to: conflict-arbiter;由 master-planner 接手派发

关联

  • 规范:§9.3
  • 决策:Q1(确定性)、Q5(deviation_score 公式见 replan-thresholds.md)
  • 智能体:master-planner——消费分类器输出用于决策引擎
  • 智能体:replanner——当类别为 F2/F3/F4 时被调用
  • 规则:rules/workflow/replan-thresholds.md——deviation_score 公式
  • 钩子:hooks/post-execute-update-node.cjs——在失败时调用此技能

状态

v3.7.0-alpha.2(Milestone B)。人类可读说明见 docs/architecture/HIERARCHICAL_PLANNING.md 或 docs/getting-started/(视主题而定)。