Remove auto-approval of user input in autopilot mode#309604
Merged
DonJayamanne merged 2 commits intomainfrom Apr 13, 2026
Merged
Remove auto-approval of user input in autopilot mode#309604DonJayamanne merged 2 commits intomainfrom
DonJayamanne merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Copilot CLI chat session integration to stop short-circuiting user_input.requested events with an automatic response when the session is in autopilot mode, aligning behavior with the intent to require explicit handling of user input prompts.
Changes:
- Removed the autopilot-only auto-response branch for
user_input.requestedinCopilotCLISession. - Ensures
user_input.requestedfollows the existingaskUserQuestion/question-carousel flow instead of injecting a hardcoded response.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts | Removes autopilot auto-response logic for user_input.requested, routing prompts through the question handler flow. |
Copilot's findings
Comments suppressed due to low confidence (2)
extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts:535
- The PR description says user input in autopilot now requires explicit user interaction, but this handler routes
user_input.requestedthroughCoreAskQuestions(viaaskUserQuestion). The built-in AskQuestions tool auto-responds whenrequest.modeInfo.permissionLevelis Autopilot, so user input may still be auto-approved. Either adjust the PR description to match the actual behavior, or change this flow/tool invocation so autopilot does not auto-answer and instead blocks until the user responds.
This issue also appears on line 522 of the same file.
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;
}
const userInputRequest: IQuestion = {
question: event.data.question,
options: (event.data.choices ?? []).map(c => ({ label: c })),
allowFreeformInput: event.data.allowFreeform,
header: event.data.question,
};
const answer = await this._userQuestionHandler.askUserQuestion(userInputRequest, this._toolInvocationToken as unknown as never, token);
flushPendingInvocationMessages();
extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts:545
- This behavior change (removing the autopilot short-circuit and always going through the question handler) isn’t covered by unit tests. Add a test that emits
user_input.requestedwithsession.setPermissionLevel('autopilot')and asserts the session delegates toIUserQuestionHandler.askUserQuestionand forwards the resulting selection/freeText torespondToUserInput(and does not send the previously hardcoded autopilot message).
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;
}
const userInputRequest: IQuestion = {
question: event.data.question,
options: (event.data.choices ?? []).map(c => ({ label: c })),
allowFreeformInput: event.data.allowFreeform,
header: event.data.question,
};
const answer = await this._userQuestionHandler.askUserQuestion(userInputRequest, this._toolInvocationToken as unknown as never, token);
flushPendingInvocationMessages();
if (!answer) {
this._sdkSession.respondToUserInput(event.data.requestId, { answer: '', wasFreeform: false });
return;
}
if (answer.freeText) {
this._sdkSession.respondToUserInput(event.data.requestId, { answer: answer.freeText, wasFreeform: true });
} else {
this._sdkSession.respondToUserInput(event.data.requestId, { answer: answer.selected.join(', '), wasFreeform: false });
}
})));
- Files reviewed: 1/1 changed files
- Comments generated: 1
Contributor
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
benvillalobos
approved these changes
Apr 13, 2026
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.
Eliminate the automatic approval of user input when in autopilot mode, requiring explicit user interaction for responses. This change enhances control over user input handling.
Fixes #307955