🤖 fix: enforce ask_user_question in Plan Mode #1169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This tightens Plan Mode guidance so agents:
ask_user_questionfor unresolved questions (instead of an “Open Questions” section / inline questions)propose_plan(the Plan UI already renders both)Validation:
make static-checkđź“‹ Implementation Plan
Reinforce
ask_user_questionusage when the agent has open questions (Plan Mode)Goal
Ensure that in Plan Mode, if the model has unanswered questions that materially affect the plan, it uses the
ask_user_questiontool (instead of outputting an “Open questions” section or asking inline in chat).Recommended approach (A): tighten the Plan Mode system instruction (primary)
Why here:
getPlanModeInstruction()is injected into the system message for every Plan Mode turn, so it’s the most reliable place to enforce behavior across models.Change: update
src/common/utils/ui/modeUtils.ts→getPlanModeInstruction()to add an explicit “no open questions in the plan; use tool” rule.Proposed wording to insert (exact text; adjust line wraps as needed):
Net LoC (product code): +8 to +15 (string expansion only).
Reinforcement (B): strengthen the tool description (secondary)
Why: tool descriptions are a strong hint for many models, and this also helps when users add
Tool: ask_user_questionoverrides (they’ll see a better base description).Change: update
src/common/utils/tools/toolDefinitions.ts→ask_user_question.description.Proposed wording tweak (replace “should be used…” with a requirement + anti-pattern callout):
Net LoC (product code): ~0 to +3 (string edit).
Tests
Add small unit tests so this behavior doesn’t regress during refactors.
src/common/utils/ui/modeUtils.test.tsgetPlanModeInstruction("/tmp/plan.md", false)containsask_user_questionandMUST.src/common/utils/tools/toolDefinitions.test.tsask_user_question.descriptioncontains the “MUST be used …” phrasing.Net LoC (product code): 0 (tests only).
Optional docs follow-up (not required for behavior)
If we want the user-facing docs to match the new behavior:
docs/plan-mode.mdx: change “may callask_user_question…” → “should/must call … when it needs clarification before finalizing a plan.”Net LoC (product code): 0 (docs only).
Validation checklist (Exec Mode)
make typecheck.bun test src/common/utils/ui/modeUtils.test.tsbun test src/common/utils/tools/toolDefinitions.test.tsask_user_questioninstead of emitting an “Open questions” section.Alternative considered: backend enforcement / linting
Idea: detect “Open Questions” patterns in the assistant output and block
propose_planunlessask_user_questionwas called.Why not (for now):
This can be revisited if prompt-only enforcement proves insufficient.
Net LoC (product code): ~50–150.
Generated with
mux• Model: openai:gpt-5.2 • Thinking: xhigh