fix(amazonq): honor agentic toggle off as plan mode (no silent edits)#2759
Draft
laileni-aws wants to merge 1 commit into
Draft
fix(amazonq): honor agentic toggle off as plan mode (no silent edits)#2759laileni-aws wants to merge 1 commit into
laileni-aws wants to merge 1 commit into
Conversation
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.
ade0512 to
030b325
Compare
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 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/fsReplaceto an in-workspace path runs without a prompt, and any MCP tool the user previously markedalwaysAllowalso runs silently.Root cause
pairProgrammingModeflows throughagenticChatController.tsonly as a telemetry dimension. Each tool'srequiresAcceptancevalidator decides whether to prompt, and those validators don't know about the toggle.requiresPathAcceptancereturnsfalsefor in-workspace paths and MCPalwaysAllowreturnsfalseregardless 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:pairProgrammingMode === false)shouldRequireAcceptanceForBuiltinToolfsWrite,fsReplace,executeBash. Read-only tools (fsRead,listDirectory,grepSearch,fileSearch) keep their normal validator output so chat can still investigate code in plan mode.shouldRequireAcceptanceForMcpToolalwaysAllow. MCP servers can have arbitrary side effects;alwaysAllowresumes when the toggle is turned back on.agenticChatController.tscalls 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
alwaysAllowtoolalwaysAllowtoolTesting
constants/toolConstants.test.tscovering:isMutatingBuiltinTool— every built-in tool name, plus unknownsshouldRequireAcceptanceForBuiltinTool— preserves behavior when toggle on; forces approval forfsWrite/fsReplace/executeBashwhen toggle off; leaves read-only tools aloneshouldRequireAcceptanceForMcpTool— preservesalwaysAllowwhen toggle on; forces approval (includingalwaysAllow) when toggle offagenticChatController.test.tsstill pass — refactoring the inline gate into named helpers did not change observable behavior in either pathtsc --noEmitclean;prettier --checkcleanOut of scope
pairProgrammingModevalue from telemetry to UX — it stays as both a telemetry dimension and (now) a behavioral gateLicense
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.