fix: block autopilot on user input requests#5090
Conversation
There was a problem hiding this comment.
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.requestedso Autopilot waits on the existing question flow. - Enhanced the Copilot CLI session test mock to emit/await
user_input.requestedend-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.requestedchecks_toolInvocationToken, but the warning says "No stream available". SincetoolInvocationTokenand stream attachment are different concerns, the message/condition reads as inconsistent. Consider either checkingthis._stream(if that’s what’s required), or updating the log text/guard to reflect the actual requirement (e.g. "No toolInvocationToken available"). Also theas unknowncast 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;
@microsoft-github-policy-service agree |
|
Thanks for the contribution! This repository has been archived because the project has moved into the main VS Code repository. Could you please reopen/recreate this PR against: We’ll continue reviewing contributions there. Thanks! |
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
Behavior Impact
Validation