fix(auto): reset _dispatching flag + improve discuss depth verification UX

- auto.ts: wrap dispatchNextUnit body in try/finally to always reset
  _dispatching to false. Without this, the reentrancy guard permanently
  blocked all subsequent dispatches after the first one, causing the
  dispatch gap watchdog to fire and auto-mode to stall.
- discuss.md: render depth summary as chat text (where markdown renders)
  then use ask_user_questions for the short confirmation only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson 2026-03-15 15:20:45 -06:00
parent 484524b528
commit e759af8e2a
2 changed files with 14 additions and 5 deletions

View file

@ -1520,7 +1520,7 @@ async function dispatchNextUnit(
return; // Another dispatch is in progress — bail silently
}
_dispatching = true;
try {
// Recursion depth guard: when many units are skipped in sequence (e.g., after
// crash recovery with 10+ completed units), recursive dispatchNextUnit calls
// can freeze the TUI or overflow the stack. Yield generously after MAX_SKIP_DEPTH.
@ -2425,6 +2425,9 @@ async function dispatchNextUnit(
);
await pauseAuto(ctx, pi);
}
} finally {
_dispatching = false;
}
}
// ─── Skill Discovery ──────────────────────────────────────────────────────────

View file

@ -91,13 +91,19 @@ Do not count the reflection step as a question round. Rounds start after reflect
## Depth Verification
Before moving to the wrap-up gate, present a structured depth summary to the user via `ask_user_questions`. This is a checkpoint — show what you captured across the depth checklist dimensions, using the user's own terminology and framing.
Before moving to the wrap-up gate, present a structured depth summary as a checkpoint.
The question should summarize: what you understood them to be building, what shaped your understanding most (their emphasis, constraints, concerns), and any areas where you're least confident in your understanding. Frame it as: "Before we move to planning, here's what I captured — did I get the depth right?"
**Print the summary as normal chat text first** — this is where the formatting renders properly. Structure the summary across the depth checklist dimensions using the user's own terminology and framing. Cover: what you understood them to be building, what shaped your understanding most (their emphasis, constraints, concerns), and any areas where you're least confident in your understanding.
**Convention:** The question ID must contain `depth_verification` (e.g., `depth_verification_summary`). This naming convention enables downstream mechanical detection of this step.
**Then** use `ask_user_questions` with a short confirmation question — NOT the summary itself. The question field is designed for single sentences, not multi-paragraph summaries.
Offer two options: "Yes, you got it (Recommended)" and "Not quite — let me clarify." If they clarify, absorb the correction and re-verify.
**Convention:** The question ID must contain `depth_verification` (e.g., `depth_verification_confirm`). This naming convention enables downstream mechanical detection of this step.
Example flow:
1. Print in chat: the full depth summary with markdown formatting (headers, bold, bullets)
2. Call `ask_user_questions` with: header "Depth Check", question "Did I capture the depth right?", options "Yes, you got it (Recommended)" and "Not quite — let me clarify"
If they clarify, absorb the correction and re-verify.
## Wrap-up Gate