mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 15:31:27 +00:00
fix: enforce plan mode restrictions in ACP sessions (issue #1806)
- 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
This commit is contained in:
parent
fb9f3fb4dc
commit
785d0ef5b7
2 changed files with 107 additions and 0 deletions
|
|
@ -516,6 +516,18 @@ export class Session implements SessionContext {
|
|||
? await invocation.shouldConfirmExecute(abortSignal)
|
||||
: false;
|
||||
|
||||
// Check for plan mode enforcement - block non-read-only tools
|
||||
const isPlanMode = this.config.getApprovalMode() === ApprovalMode.PLAN;
|
||||
if (isPlanMode && !isExitPlanModeTool && confirmationDetails) {
|
||||
// In plan mode, block any tool that requires confirmation (write operations)
|
||||
return errorResponse(
|
||||
new Error(
|
||||
`Plan mode is active. The tool "${fc.name}" cannot be executed because it modifies the system. ` +
|
||||
'Please use the exit_plan_mode tool to present your plan and exit plan mode before making changes.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (confirmationDetails) {
|
||||
const content: acp.ToolCallContent[] = [];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue