fix: enforce plan mode restrictions in ACP sessions#1812
Merged
Conversation
- Add plan mode enforcement in Session.runTool to block write tools - Align ACP behavior with CoreToolScheduler plan mode logic - Add test case to verify write tools are blocked in plan mode - Fixes #1806
Contributor
📋 Review SummaryThis PR fixes issue #1806 by properly enforcing plan mode restrictions in ACP sessions. The changes ensure that when a session is in plan mode, write operations like file edits and shell commands are blocked, aligning ACP behavior with the CoreToolScheduler used in CLI interactive mode. 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
✅ Highlights
|
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
…nforcement fix: enforce plan mode restrictions in ACP sessions
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.
TLDR
Fixes #1806 - ACP session/set_mode("plan") now correctly blocks write tools (edit, write_file, run_shell_command) to enforce read-only/analysis-only behavior.
Dive Deeper
Problem
When using ACP protocol, calling
session/set_modewithmodeId: "plan"returned success but didn't enforce plan mode restrictions - the agent could still execute file edits and commands.Root Cause
Session.runTool()in ACP integration lacked plan mode enforcement logic that exists inCoreToolScheduler(used by CLI interactive mode and SDK).Solution
Added plan mode check in
Session.runTool()to block tools requiring confirmation (write operations) when in plan mode, exceptexit_plan_modetool. This aligns ACP behavior with CoreToolScheduler.Changes
blocks write tools in plan mode (issue #1806)to verify enforcementReviewer Test Plan
qwen --acpsession/set_mode {modeId: "plan"}Testing Matrix
Linked issues / bugs
Fixes #1806