Skip to content

fix(amazonq): honor agentic toggle off as plan mode (no silent edits)#2759

Draft
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/agentic-toggle-honors-plan-mode
Draft

fix(amazonq): honor agentic toggle off as plan mode (no silent edits)#2759
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/agentic-toggle-honors-plan-mode

Conversation

@laileni-aws

@laileni-aws laileni-aws commented May 30, 2026

Copy link
Copy Markdown
Contributor

Problem

When a user disables the agentic coding toggle in chat, they expect the assistant to ask permission before modifying any file or running any command — that is the toggle's whole purpose. Today the toggle is wired only into telemetry, so disabling it has no observable effect: the next fsWrite / fsReplace to an in-workspace path runs without a prompt, and any MCP tool the user previously marked alwaysAllow also runs silently.

Root cause

pairProgrammingMode flows through agenticChatController.ts only as a telemetry dimension. Each tool's requiresAcceptance validator decides whether to prompt, and those validators don't know about the toggle. requiresPathAcceptance returns false for in-workspace paths and MCP alwaysAllow returns false regardless of toggle state — so write/exec tools execute silently when the user expected plan-mode behavior.

Solution

Treat agentic mode off ⇢ plan mode: a strict "review everything" intent that overrides per-tool/per-path approvals until the toggle is turned back on.

Two pure helpers in constants/toolConstants.ts:

Helper Behavior in plan mode (pairProgrammingMode === false)
shouldRequireAcceptanceForBuiltinTool Forces approval for fsWrite, fsReplace, executeBash. Read-only tools (fsRead, listDirectory, grepSearch, fileSearch) keep their normal validator output so chat can still investigate code in plan mode.
shouldRequireAcceptanceForMcpTool Forces approval for every MCP tool, including those marked alwaysAllow. MCP servers can have arbitrary side effects; alwaysAllow resumes when the toggle is turned back on.

agenticChatController.ts calls these helpers at the two existing acceptance gates (built-in tool branch and MCP tool branch). When agentic mode is on, the helpers are pass-throughs — existing behavior is preserved exactly.

The mutating-tool list lives in a single named ReadonlySet (MUTATING_BUILTIN_TOOLS) to keep the rule discoverable for future tool additions.

Behavior matrix

Scenario Before After
Toggle ON, fsWrite to workspace file runs silently ✅ runs silently ✅
Toggle ON, MCP alwaysAllow tool runs silently ✅ runs silently ✅
Toggle ON, fsWrite to outside workspace prompts ✅ prompts ✅
Toggle OFF, fsWrite to workspace file runs silently (bug) prompts ✅
Toggle OFF, fsReplace to workspace file runs silently (bug) prompts ✅
Toggle OFF, MCP alwaysAllow tool runs silently prompts ✅
Toggle OFF, fsRead/grepSearch/listDirectory in workspace runs silently runs silently (chat can still plan)

Testing

  • 19 new unit tests in constants/toolConstants.test.ts covering:
    • isMutatingBuiltinTool — every built-in tool name, plus unknowns
    • shouldRequireAcceptanceForBuiltinTool — preserves behavior when toggle on; forces approval for fsWrite / fsReplace / executeBash when toggle off; leaves read-only tools alone
    • shouldRequireAcceptanceForMcpTool — preserves alwaysAllow when toggle on; forces approval (including alwaysAllow) when toggle off
  • All 95 existing tests in agenticChatController.test.ts still pass — refactoring the inline gate into named helpers did not change observable behavior in either path
  • tsc --noEmit clean; prettier --check clean
$ npx ts-mocha "./src/language-server/agenticChat/constants/toolConstants.test.ts"
  19 passing (5ms)

$ npx ts-mocha "./src/language-server/agenticChat/agenticChatController.test.ts"
  95 passing (1s)

Out of scope

  • Re-routing the pairProgrammingMode value from telemetry to UX — it stays as both a telemetry dimension and (now) a behavioral gate
  • Adding a "plan mode" badge in the UI — separate change for the chat UI layer if desired
  • Eclipse / Visual Studio behavior is identical to JetBrains and VS Code because they share this language server; the fix lands in all four IDE plugins simultaneously when they pick up the next manifest

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When the user turned the agentic-coding toggle off, chat still applied
fsWrite/fsReplace/executeBash and alwaysAllow MCP tools without prompting,
because pairProgrammingMode was wired only to telemetry. Force approval for
every mutating built-in tool and every MCP tool while the toggle is off; keep
read-only tools (fsRead/listDirectory/grepSearch/fileSearch) free so chat can
still investigate the codebase in plan mode.
@laileni-aws laileni-aws force-pushed the fix/agentic-toggle-honors-plan-mode branch from ade0512 to 030b325 Compare May 30, 2026 01:28
@codecov-commenter

codecov-commenter commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.14925% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.98%. Comparing base (38cc4f8) to head (030b325).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...nguage-server/agenticChat/agenticChatController.ts 9.09% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2759      +/-   ##
==========================================
- Coverage   58.01%   57.98%   -0.04%     
==========================================
  Files         280      281       +1     
  Lines       70500    70790     +290     
  Branches     4234     4251      +17     
==========================================
+ Hits        40903    41049     +146     
- Misses      29511    29655     +144     
  Partials       86       86              
Flag Coverage Δ
unittests 57.98% <70.14%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants