competing-hypotheses

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Competing Hypotheses

多假设并行调试法

Debug problems by racing multiple theories in parallel. Each investigator pursues a different hypothesis, gathers evidence, and reports back. The lead compares findings to identify the root cause.
通过并行验证多种理论来调试问题。每个调查Agent追踪一个不同的假设,收集证据并反馈结果。主导Agent会对比所有调查结果以确定根本原因。

When to Use

适用场景

  • "I have no idea why this is broken"
  • A bug that could have multiple root causes
  • Unexpected behaviour with no obvious source
  • Performance regressions with unclear origin
  • Intermittent failures that are hard to reproduce

  • “我不知道为什么程序出问题了”
  • 可能存在多个根本原因的bug
  • 无明显诱因的意外行为
  • 根源不明的性能退化问题
  • 难以复现的间歇性故障

Instructions for Claude

给Claude的操作指南

You are the lead investigator coordinating a parallel hypothesis investigation.
你是首席调查官,负责协调多假设并行调查工作。

Phase 1: Hypothesize

阶段1:提出假设

  1. Understand the problem from the user's input:
    • What's the symptom? (error message, wrong output, unexpected behaviour)
    • When does it happen? (always, sometimes, after a recent change)
    • What's already been tried?
  2. Generate 2-5 plausible hypotheses for the root cause
    • Each should be distinct and testable
    • Cover different areas (data, logic, infrastructure, external dependencies, timing)
  3. Present the hypotheses to the user:
    • List each hypothesis with a brief rationale
    • Ask: "I'll spin up N investigators to pursue these in parallel. Proceed?"
    • Incorporate any hypotheses the user wants to add or remove
  1. 从用户输入中理解问题:
    • 症状是什么?(错误信息、输出异常、意外行为)
    • 问题何时出现?(始终出现、偶尔出现、某次变更后出现)
    • 已经尝试过哪些解决方法?
  2. 生成2-5个合理的根本原因假设
    • 每个假设都应独特且可验证
    • 覆盖不同领域(数据、逻辑、基础设施、外部依赖、时序问题)
  3. 向用户展示假设:
    • 列出每个假设并附上简要依据
    • 询问:“我将启动N个调查Agent并行追踪这些假设。是否继续?”
    • 纳入用户想要添加或移除的任何假设

Phase 2: Parallel Investigation

阶段2:并行调查

  1. Create a team with
    TeamCreate
  2. Create tasks for each hypothesis with
    TaskCreate
  3. Spawn one
    general-purpose
    teammate per hypothesis using
    Task
    with
    team_name
    • Name them after their hypothesis (e.g.,
      race-condition-investigator
      ,
      data-corruption-investigator
      )
    • Each investigator's prompt should include:
      • The overall problem description
      • Their specific hypothesis to pursue
      • Instruction to investigate only, do not make changes
      • What evidence to look for (see Investigation Guide below)
      • Instruction to report findings via
        SendMessage
  4. Spawn all investigators in parallel
  5. As investigators report back, give the user brief progress updates — don't wait silently for all of them
  6. If an investigator discovers a recent commit already resolved the issue, report the finding to the user and end early if they confirm it's fixed
  1. 使用
    TeamCreate
    创建一个团队
  2. 使用
    TaskCreate
    为每个假设创建任务
  3. 通过带有
    team_name
    参数的
    Task
    工具,为每个假设生成一个
    通用型
    队友
    • 以对应的假设为其命名(例如:
      race-condition-investigator
      data-corruption-investigator
    • 每个调查Agent的提示语应包含:
      • 整体问题描述
      • 他们需要追踪的特定假设
      • 指令:仅进行调查,不要做出任何修改
      • 需要寻找的证据类型(见下方调查指南)
      • 指令:通过
        SendMessage
        报告调查结果
  4. 并行生成所有调查Agent
  5. 当调查Agent反馈结果时,向用户提供简短的进度更新——不要默默等待所有结果
  6. 如果某个调查Agent发现最近的提交已经解决了问题,向用户报告该发现,若用户确认问题已修复则提前结束流程

Subagent Guidance for Investigators

给调查子Agent的指导说明

Include the following in each investigator's prompt:
Use subagents (
Task
tool) to keep your context focused.
Spawn subagents for:
  • Exploring specific files, modules, or subsystems
  • Searching through git history, logs, or large codebases
  • Any research tangent that might not pan out
Each subagent should report back:
  1. Relevant findings — what it discovered that matters to your investigation
  2. Red herrings (1-2 sentences) — anything that looks related but isn't, and why. Calling these out early prevents wasted cycles re-exploring dead ends.
Report red herrings even when your main findings are conclusive — they prevent other agents from re-exploring the same dead ends.
After receiving a subagent's report, decide whether to:
  • Use its findings directly — if the summary gives you enough to proceed
  • Dive in yourself — if the subagent found something promising and you want full, first-hand context in that area before drawing conclusions. Examples: conflicting evidence that needs direct examination, low confidence in the subagent's assessment, or complex state/flow where first-hand context matters.
When choosing subagent types, prefer read-only or exploration-focused types for open-ended codebase searches, and full-capability types for targeted analysis or tasks that need write access.
在每个调查Agent的提示语中加入以下内容:
使用子Agent(
Task
工具)来保持你的上下文聚焦。
在以下场景生成子Agent:
  • 探索特定文件、模块或子系统
  • 搜索Git历史、日志或大型代码库
  • 任何可能没有结果的研究分支
每个子Agent应反馈:
  1. 相关发现 —— 与你的调查相关的内容
  2. 干扰项(1-2句话)—— 任何看起来相关但实际无关的内容,以及原因。尽早指出这些内容可以避免重复探索死胡同的无效工作。
即使你的主要结论已经确定,也要报告干扰项——这可以防止其他Agent重复探索相同的死胡同。
收到子Agent的报告后,决定:
  • 直接使用其发现 —— 如果摘要足够让你继续推进
  • 亲自深入研究 —— 如果子Agent发现了有希望的线索,而你需要该领域完整的一手上下文才能得出结论。例如:需要直接检查的矛盾证据、对子Agent评估结果信心不足,或需要一手上下文的复杂状态/流程。
选择子Agent类型时,对于开放式代码库搜索,优先选择只读或专注于探索的类型;对于针对性分析或需要写入权限的任务,选择全功能类型。

Investigation Guide

调查指南

Each investigator should:
  1. Search for evidence supporting their hypothesis
    • Read relevant code paths
    • Check logs, error messages, stack traces if available
    • Look at recent changes (git log, git diff) that could be related
    • Examine configuration, environment, data
  2. Search for counter-evidence that would disprove their hypothesis
  3. Rate their confidence based on what they found
  4. Report using the output format below
每个调查Agent应:
  1. 寻找支持其假设的证据
    • 阅读相关代码路径
    • 检查日志、错误信息、可用的堆栈跟踪
    • 查看可能相关的近期变更(Git日志、Git差异)
    • 检查配置、环境和数据
  2. 寻找能推翻其假设的反证
  3. 根据发现的内容评估自己的信心程度
  4. 使用以下输出格式报告结果

Investigator Output Format

调查Agent输出格式

undefined
undefined

Hypothesis: {description}

Hypothesis: {description}

Evidence For

Evidence For

  • {evidence point}: {where found, what it means}
  • {evidence point}: {where found, what it means}

Evidence Against

Evidence Against

  • {evidence point}: {where found, what it means}
  • {evidence point}: {where found, what it means}

Red Herrings

Red Herrings

  • {code paths or areas explored that looked related but weren't, and why}
  • {code paths or areas explored that looked related but weren't, and why}

Confidence: {high/medium/low}

Confidence: {high/medium/low}

Root Cause (if found)

Root Cause (if found)

{specific root cause, file, line, mechanism}
{specific root cause, file, line, mechanism}

Suggested Fix

Suggested Fix

{what to change and why}
{what to change and why}

Open Questions

Open Questions

  • {anything unresolved that could help narrow it down}
undefined
  • {anything unresolved that could help narrow it down}
undefined

Phase 3: Compare & Conclude

阶段3:对比与总结

  1. Once all investigators have reported, compare findings:
    • Which hypothesis has the strongest evidence?
    • Did any investigator find definitive proof?
    • Do findings from different investigators corroborate each other?
    • Are there open questions that could be quickly resolved?
    • Compound bugs — if multiple hypotheses are confirmed, present as a multi-root-cause scenario and propose fixing in dependency order (fix the cause that enables the others first)
  2. Present the analysis to the user:
    • Rank hypotheses by evidence strength
    • Highlight the most likely root cause
    • Note any surprising findings or ruled-out theories
    • Recommend next steps (fix, further investigation, or targeted test)
  1. 当所有调查Agent都提交报告后,对比结果:
    • 哪个假设的证据最充分?
    • 是否有调查Agent找到了确凿的证据?
    • 不同调查Agent的发现是否相互印证?
    • 是否存在可以快速解决的未决问题?
    • 复合bug —— 如果多个假设都被证实,将其作为多根本原因场景呈现,并建议按依赖顺序修复(先修复引发其他问题的原因)
  2. 向用户展示分析结果:
    • 根据证据强度对假设进行排序
    • 突出最可能的根本原因
    • 记录任何意外发现或被排除的理论
    • 推荐下一步行动(修复、进一步调查或针对性测试)

Phase 4: Fix (Optional)

阶段4:修复(可选)

Skip this phase if the user only wanted diagnosis, not a fix.
  1. If the root cause is clear and the user wants to proceed:
    • Message the investigator who found it to implement the fix
    • They already have full context from their investigation
  2. If the root cause is unclear:
    • Propose targeted experiments to disambiguate
    • Ask the user which direction to pursue
  3. After any fix, spawn a fresh
    validator
    teammate to verify the fix addresses the original symptom. The validator's spawn prompt must include: the original symptom, the confirmed hypothesis/root cause, and what the fix was intended to do.
  4. If validation fails, route the failure back to the investigator who implemented the fix for corrections, then re-validate
如果用户只需要诊断而不需要修复,则跳过此阶段。
  1. 如果根本原因明确且用户希望继续:
    • 通知找到该原因的调查Agent来实施修复
    • 他们已经从调查中掌握了完整的上下文
  2. 如果根本原因不明确:
    • 提出针对性实验来消除歧义
    • 询问用户希望朝哪个方向推进
  3. 完成任何修复后,生成一个新的
    validator
    队友来验证修复是否解决了原始症状。生成验证Agent的提示语必须包含:原始症状、已确认的假设/根本原因,以及修复的预期目标。
  4. 如果验证失败,将失败结果反馈给实施修复的调查Agent进行修正,然后重新验证

Rules

规则

  • Keep investigators alive until the conclusion — they may need follow-up questions
  • 2-5 hypotheses max — too many dilutes focus
  • Investigators don't communicate — they work independently to avoid confirmation bias
  • Evidence over intuition — rank hypotheses by concrete evidence, not plausibility
  • Counter-evidence matters — a hypothesis with strong counter-evidence should be deprioritized even if it seems likely
  • Shut down when done — after validation passes, or after the user declines to fix, shut down all teammates and report results
  • 保留调查Agent直到流程结束 —— 他们可能需要回答后续问题
  • 最多2-5个假设 —— 过多假设会分散注意力
  • 调查Agent之间不沟通 —— 他们独立工作以避免确认偏差
  • 证据优先于直觉 —— 根据具体证据对假设排序,而非合理性
  • 反证至关重要 —— 即使某个假设看似合理,若存在有力反证也应降低其优先级
  • 完成后关闭所有Agent —— 验证通过后,或用户拒绝修复后,关闭所有队友并报告结果