feat: add plan mode — agent asks clarifying questions before running#38
Conversation
Per-message toggle in the chat input. When on, the request includes plan_mode=true and the backend appends a directive to the system prompt telling the agent to ask 1–3 numbered clarifying questions and skip all tool use for that turn. Toggle auto-resets to off after send so follow-ups proceed normally. Backend: - ChatRequest gains plan_mode: bool = False - _build_system_blocks(plan_mode) appends PLAN_MODE_DIRECTIVE AFTER the cache_control breakpoint, so toggling plan mode does not invalidate the cached base prompt Frontend: - planMode state in ChatPage, plan_mode in the fetch body - Toggle button (IconBulb) in the input footer, always visible, reset in sendMessage Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Beta preview has been cleaned up because this PR was closed. |
SakshiKekre
left a comment
There was a problem hiding this comment.
Great idea adding the plan mode! The UI shape looks reasonable, I just think the backend should enforce plan mode rather than relying only on prompt text.
Right now plan_mode=true appends PLAN_MODE_DIRECTIVE, but the request still sends the normal tool list to Anthropic. If the model ignores the directive and emits a tool call, the existing loop will execute it. Since the feature promise is “ask clarifying questions before running tools,” could we make that invariant code-level?
Non-blocking,suggestion: Could we also add a small backend regression test for that contract? Suggested shape:
- assert
_build_system_blocks(plan_mode=True)includesPLAN_MODE_DIRECTIVE
Address review feedback: plan mode previously relied on the model obeying a system-prompt directive while still being given the full tool list. Now plan_mode=True omits `tools` from the Anthropic call entirely, so tool_use blocks cannot be emitted. A defence-in-depth guard drops any tool_use that surfaces anyway. Adds regression tests covering the directive, cache breakpoint, and request schema. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks @SakshiKekre — good catch. Pushed 82baaf4:
|
Summary
Adds a per-message Plan mode toggle to the chat input. When on, the agent asks 1–3 numbered clarifying questions before running any tools, then proceeds normally on the next turn once the user replies. Modeled after Claude Code's plan mode.
Policy questions are routinely ambiguous ("model a wealth tax", "abolish NI", "raise the personal allowance"). Running a 30-second simulation on the wrong assumptions is worse than asking a 5-second clarifying question first.
Behaviour
plan_mode: true.PLAN_MODE_DIRECTIVEto the system prompt — agent responds with 1–3 numbered questions, no tool calls.Backend
ChatRequestgainsplan_mode: bool = False.PLAN_MODE_DIRECTIVEtells the model: don't call tools, ask 1–3 numbered clarifying questions, numbered list, no preamble._build_system_blocks(plan_mode)appends the directive after thecache_controlbreakpoint so toggling plan mode never invalidates the cached base prompt.Frontend
planModestate inChatPage.tsx, sent asplan_modein the POST body.IconBulb) in the input footer — always visible, styled as a pill that flips to the accent colour when on.sendMessageresetsplanModetofalseafter capturing it for the current send.Smoke test (passed)
curlwithplan_mode=trueand "Abolish national insurance" → 3 numbered clarifying questions (year, which NICs, what metric), zero tool calls.curlwithplan_mode=falseand a normal question → immediaterun_pythontool use.Test plan
docker-compose up→ open http://localhost:3006🤖 Generated with Claude Code