Skip to content

fix(amazonq): honor agentic OFF state across chat lifecycle - #2905

Open
laileni-aws wants to merge 1 commit into
feature/OHIfrom
fix/agentic-off-state-p483027148
Open

laileni-aws wants to merge 1 commit into
feature/OHIfrom
fix/agentic-off-state-p483027148

Conversation

@laileni-aws

Copy link
Copy Markdown
Collaborator

Problem

The agentic coding switch can display OFF while the server session remains ON. Tab creation initializes server mode from a global preference, while history restoration applies the saved per-tab mode only to the UI. The displayed mode included in normal prompt submissions was not consumed by the server. Early mode changes could also be lost before the history database finished loading.

Separately, a tool could pass its initial mode check and still dispatch after the user switched OFF during an asynchronous permission check or approval wait.

Related public report: Amazon-Q-Developer/amazon-q-vscode#160

Solution

  • Initialize sessions from effective per-tab preferences and deny write access while mode is unknown. Preserve an existing session's mode when a late/repeated tab-add notification arrives.
  • Apply explicit prompt mode before request preparation. Keep the current mode for clients that omit this optional field; only the explicit string true enables it.
  • Restore server mode after establishing the history mapping and before notifying the UI.
  • Buffer mode changes received before database initialization. Flush per-tab choices while preserving the final global selection and unrelated loaded settings.
  • Preserve mode on model-only option events.
  • Reject pending restricted-tool approvals when mode becomes OFF. Recheck tool availability before registering an approval and immediately before dispatch, after asynchronous checks and document reads.
  • Add regression coverage for initialization, restoration ordering, prompt options, pending approvals, dispatch races, and read-tool availability.

Scope: seven files in server/aws-lsp-codewhisperer. No dependency or deployment changes.

Testing

  • npm run compile: passed with Node 22.16.0 and Node 24.13.0.
  • Five focused controller/database/session suites: 207 passing on both runtimes.
  • Complete agenticChat/**/*.test.ts and chat/**/*.test.ts directories on Node 24.13.0: 1,252 passing, 9 pending, with normal runner completion.
  • ESLint on all seven changed files and git diff --check: passed.
  • Mandatory local pre-review used auto-cr-reviewer: all seven files and 28 hunks reviewed through the structured diff parser, followed by deduplication, confidence, compliance, and refinement passes. No actionable findings. No repository custom rules were present.

Node 24 checks ran in a local Amazon Linux container with networking disabled and an isolated home directory because the host glibc cannot launch the official Node 24 binary.

Verification limits / handoff

  • The exact customer incident is not reproduced end-to-end. The reported extension version does not identify its separately downloaded language-server version, and no incident logs were available.
  • No live VSCode or other IDE integration test was run. Model calls, tool dispatch, and filesystem effects are mocked in the regression tests.
  • The full package suite is not certified: the Node 22 run stopped at an unchanged, filesystem-state-dependent ProfileStatusMonitor assertion. The Node 24 invocation exited successfully without a completion summary; existing process.exit(0) calls in unrelated test files can terminate that run early. The completed chat-directory run above is the broader verified result.
  • OFF prevents restricted actions that have not yet been dispatched. This does not roll back completed writes or promise cancellation of an already-running tool.
  • Until mode is known, an uninitialized session remains read-only. An explicit ON choice still enables agentic tools.

Draft only. No reviewers requested. Human review and IDE integration validation remain before publication or merge.

License

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

@laileni-aws
laileni-aws changed the base branch from main to feature/OHI October 5, 2026 22:34
@laileni-aws
laileni-aws marked this pull request as ready for review October 5, 2026 22:49
@laileni-aws
laileni-aws requested a review from a team as a code owner October 5, 2026 22:49
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 96.66667% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...language-server/agenticChat/tools/chatDb/chatDb.ts 94.28% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

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