fix: enforce plan mode in ACP session to block non-read-only tools (#1806) - #1839
Closed
echoVic wants to merge 1 commit into
Closed
fix: enforce plan mode in ACP session to block non-read-only tools (#1806)#1839echoVic wants to merge 1 commit into
echoVic wants to merge 1 commit into
Conversation
…wenLM#1806) When using Qwen Code via ACP protocol (--acp), calling session/set_mode with modeId 'plan' returned success but did not actually enforce plan mode restrictions. The agent would still execute file edits and shell commands. Root cause: The ACP Session.runTool() method lacked the plan mode check that exists in coreToolScheduler.ts. When a tool required confirmation (confirmationDetails was truthy), it would proceed to requestPermission instead of blocking the tool in plan mode. Fix: Add plan mode enforcement in Session.runTool() that mirrors the logic in coreToolScheduler.ts — when in plan mode, non-read-only tools (except exit_plan_mode) are blocked and return the plan mode system reminder instead of requesting user permission. Fixes QwenLM#1806
echoVic
requested review from
DennisYu07,
LaZzyMan,
Mingholy,
gwinthis,
pomelo-nwu and
tanzhenxin
as code owners
February 14, 2026 07:31
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When using Qwen Code via ACP protocol (
qwen --acp), callingsession/set_modewithmodeId: "plan"returns success but does not actually enforce plan mode restrictions. The agent still executes file edits and shell commands as if in default mode.Root Cause
The ACP
Session.runTool()method inpackages/cli/src/acp-integration/session/Session.tslacks the plan mode check that exists incoreToolScheduler.ts.In
coreToolScheduler.ts(interactive CLI mode):In ACP
Session.runTool()(before this fix):So when a tool requires confirmation (e.g., file edit, shell command), the ACP path would ask the user for permission instead of blocking it outright in plan mode.
Fix
Add plan mode enforcement in
Session.runTool()that mirrors the logic incoreToolScheduler.ts:When in plan mode, non-read-only tools (except
exit_plan_mode) are blocked and return the plan mode system reminder to the model, instead of requesting user permission.All 10 existing Session tests pass.
Fixes #1806