fix: prevent infinite self-discuss loop in auto/headless mode (#1426)
When running in --auto or headless mode, the discuss step could loop indefinitely — each pass reads its own CONTEXT.md, finds "gaps" in referenced types/interfaces, creates new decisions to fill them, and repeats. Observed: 34 passes, 167 decisions, 7 hours, zero code written. Fixes: - Add max_discuss_passes config (default: 3) to WorkflowConfig - Add single-pass guard instruction to SDK self-discuss prompt - Add pass cap documentation to CLI discuss-phase workflow - Add pass guard step to SDK headless discuss-phase prompt - Add stall detection note to autonomous workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,19 @@ Analyze the phase to identify gray areas:
|
||||
5. **Log each decision** with rationale
|
||||
</step>
|
||||
|
||||
<step name="pass_guard">
|
||||
**CRITICAL — Single-pass guard:**
|
||||
This step MUST complete in ONE pass. After writing CONTEXT.md, you are DONE. Do NOT re-read your own CONTEXT.md to identify "gaps", "undefined types", or "missing references" and run additional passes. Each decision naturally references other types and interfaces — this is expected, not a gap. The planner and executor will handle implementation details.
|
||||
|
||||
Self-referential gap-finding creates an infinite loop where:
|
||||
1. Pass N creates decisions referencing types/interfaces
|
||||
2. Pass N+1 "discovers" those references as "gaps"
|
||||
3. Pass N+1 creates new decisions that reference more types
|
||||
4. Repeat forever
|
||||
|
||||
Write your decisions once, comprehensively, then stop.
|
||||
</step>
|
||||
|
||||
<step name="write_context">
|
||||
Create CONTEXT.md capturing decisions made:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user