Skip to content

fix: block autopilot on user input requests#5090

Open
unveroleone wants to merge 1 commit intomicrosoft:mainfrom
unveroleone:fix/autopilot-askquestions-blocking
Open

fix: block autopilot on user input requests#5090
unveroleone wants to merge 1 commit intomicrosoft:mainfrom
unveroleone:fix/autopilot-askquestions-blocking

Conversation

@unveroleone
Copy link
Copy Markdown

Summary

Autopilot was incorrectly auto-answering clarification prompts and continuing execution without waiting for real user input.
This PR makes clarification questions in Autopilot a true pause point by removing the self-answering path and always routing through the existing question flow.

Root Cause

In copilotcliSession.ts, the user_input.requested handler had an Autopilot-only shortcut that immediately replied with a canned freeform answer instead of waiting for the question UI result.

What Changed

  1. Removed the Autopilot auto-response branch from copilotcliSession.ts.
  2. Kept the normal askUserQuestion path for user_input.requested in all modes, including Autopilot.
  3. Added regression coverage in copilotcliSession.spec.ts to verify:
  • Autopilot user_input.requested returns the selected choice from user input.
  • Autopilot user_input.requested returns freeform text from user input.
  1. Enhanced the test mock session in copilotcliSession.spec.ts so user_input requests can be emitted and awaited end-to-end.

Behavior Impact

  1. Clarification questions in Autopilot now require explicit user input before continuation.
  2. Existing Autopilot behavior for permission auto-approval and exit plan mode remains unchanged.

Validation

  1. Targeted tests passed:
  • npx vitest run copilotcliSession.spec.ts
  • Result: 45 passed, 0 failed
  1. Watch compilers reported no TypeScript errors:
  • watch:tsc-extension
  • watch:tsc-extension-web
  • watch:tsc-simulation-workbench
  1. esbuild watch completed builds successfully.

Copilot AI review requested due to automatic review settings April 27, 2026 16:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Copilot CLI Autopilot incorrectly auto-answering clarification prompts by removing the Autopilot-only shortcut and always routing user_input.requested through the standard user question flow, with regression tests to prevent reintroduction.

Changes:

  • Removed the Autopilot “self-answer” branch for user_input.requested so Autopilot waits on the existing question flow.
  • Enhanced the Copilot CLI session test mock to emit/await user_input.requested end-to-end.
  • Added unit tests covering Autopilot returning both selected-choice and freeform user-input responses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/extension/chatSessions/copilotcli/node/copilotcliSession.ts Removes Autopilot’s auto-response path for user_input.requested, forcing the normal user-question handling path.
src/extension/chatSessions/copilotcli/node/test/copilotcliSession.spec.ts Adds mock support + regression tests to validate Autopilot waits for and returns user-provided input.
Comments suppressed due to low confidence (1)

src/extension/chatSessions/copilotcli/node/copilotcliSession.ts:520

  • The guard for user_input.requested checks _toolInvocationToken, but the warning says "No stream available". Since toolInvocationToken and stream attachment are different concerns, the message/condition reads as inconsistent. Consider either checking this._stream (if that’s what’s required), or updating the log text/guard to reflect the actual requirement (e.g. "No toolInvocationToken available"). Also the as unknown cast is unnecessary here; if (!this._toolInvocationToken) is clearer.
			disposables.add(toDisposable(this._sdkSession.on('user_input.requested', async (event) => {
				if (!(this._toolInvocationToken as unknown)) {
					this.logService.warn('[AskQuestionsTool] No stream available, cannot show question carousel');
					this._sdkSession.respondToUserInput(event.data.requestId, { answer: '', wasFreeform: false });
					return;

@unveroleone
Copy link
Copy Markdown
Author

@unveroleone please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microslop-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microslop-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microslop-github-policy-service agree company="Microslop"

Contributor License Agreement

@microsoft-github-policy-service agree

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