Repository navigation
Adapt onShellAuthenticationRequest for sudo, ssh, and git passwords in chat - #348067
Merged
Anthony Kim (anthonykim1) merged 13 commits intoNov 13, 2026
Merged
Conversation
When a command run by the Copilot agent asks for a password, a passphrase, or a yes/no confirmation (`sudo -A`, `ssh`, or `git`), the agent host now registers the SDK's `onShellAuthenticationRequest` handler, and VS Code shows the prompt as a question in the chat: a masked input for secrets, the command that asked, and a note that the answer goes only to that program. - The chat input request carries the prompt in `_meta`, never the answer. VS Code sends the answer with the new `vscode/answerShellAuthentication` request, outside chat state, and the AHP traffic log redacts it. A `chat/inputCompleted` for these requests only cancels them. - Clients that don't know these prompts get a single "Cancel Prompt" choice with free text turned off, so they don't offer a text box whose answer would be stored in chat state. VS Code has honored `allowFreeformInput` on response-part input requests since July 2026. - Prompts are cancelled in autopilot, with auto-reply, without an active turn, and when the SDK no longer needs the answer. - Question carousels gain a `password` flag: masked input, no drafts, and only the carousel's completion receives the answer; stored and shown answers are masked. Voice doesn't read or answer these questions. - Question descriptions wrap long words, such as ssh host key fingerprints.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Shell passwords are exposed as plaintext to Web PubSub/Mission Control relays, and non-secret prompt answers are serialized despite assurances that they are not saved in chat.
2 open issues
What changed in this PR
This PR adds in-chat authentication prompts for Copilot SDK shell commands, addressing part of #341462 without adding visible interactive terminals.
Changes:
- Connects SDK authentication callbacks to chat prompts and a dedicated answer request outside protocol chat state.
- Adds masked password inputs, secret-answer redaction, voice restrictions, and cancellation handling.
- Adds regression tests and documents the extension request.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatQuestionCarouselPart.test.ts | Tests masked inputs and password draft exclusion. |
| src/vs/workbench/contrib/chat/test/browser/voiceClient/voiceToolDispatchService.test.ts | Tests rejection of spoken password answers. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts | Tests restored authentication prompt history. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Tests prompt presentation, answer routing, and cancellation. |
| src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatQuestionCarouselData.ts | Masks stored password answers. |
| src/vs/workbench/contrib/chat/common/chatService/chatService.ts | Adds the password question flag. |
| src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts | Masks answers before storage and notifications. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatQuestionCarousel.css | Wraps long prompt descriptions. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts | Implements password inputs and masked summaries. |
| src/vs/workbench/contrib/chat/browser/voiceClient/voiceToolDispatchService.ts | Blocks voice responses to password questions. |
| src/vs/workbench/contrib/chat/browser/voiceClient/voiceSessionController.ts | Excludes password prompts from voice handling. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts | Builds authentication carousels and restored history. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Routes answers and synchronizes prompt completion. |
| src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts | Tests request routing and parameter validation. |
| src/vs/platform/agentHost/test/node/copilotSessionLauncherTestHelpers.ts | Adds the authentication callback test stub. |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Tests authentication delivery and cancellation. |
| src/vs/platform/agentHost/test/common/ahpJsonlLogger.test.ts | Tests answer redaction, including oversized entries. |
| src/vs/platform/agentHost/node/protocolServerHandler.ts | Validates and handles authentication answer requests. |
| src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts | Registers the SDK authentication callback. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Manages pending prompts and SDK responses. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Routes answers to the owning chat. |
| src/vs/platform/agentHost/node/agentService.ts | Routes answers through the owning provider. |
| src/vs/platform/agentHost/electron-browser/localAgentHostService.ts | Forwards local authentication answers. |
| src/vs/platform/agentHost/common/meta/vscode/agentShellAuthenticationMeta.ts | Defines prompt metadata and cancel-only fallback. |
| src/vs/platform/agentHost/common/meta/vscode/agentChatInputRequestMeta.ts | Adds the shell-authentication request purpose. |
| src/vs/platform/agentHost/common/meta/agentShellAuthenticationMeta.ts | Exposes shared metadata helpers. |
| src/vs/platform/agentHost/common/ahpJsonlLogger.ts | Redacts authentication answer payloads. |
| src/vs/platform/agentHost/common/agentService.ts | Extends service and connection contracts. |
| src/vs/platform/agentHost/common/agentHostExtensionProtocol.ts | Defines the answer request and result contract. |
| src/vs/platform/agentHost/common/agent.ts | Adds the provider answer interface. |
| src/vs/platform/agentHost/browser/nullAgentHostService.ts | Adds the unsupported-service implementation. |
| src/vs/platform/agentHost/browser/agentHostProtocolClient.ts | Sends authentication answer requests. |
| src/vs/platform/agentHost/AGENTS.md | Documents authentication transport and lifecycle. |
Review effort: Balanced
Drop the comments on shell authentication code where the neighboring code has none, such as enum members, extension method ids, interface fields, and input request helpers, and shorten the rest to the length of their neighbors. Restore the upstream wording of comments this change extended.
Change "Your answer goes only to {0}. It isn't sent to the model or saved
in the chat." to "Your answer goes only to {0} and isn't sent to the model
or saved in the chat."
Add `chat.agentHost.copilot.shellAuthentication.enabled`, on by default and tagged experimental, and mirror it to the host root setting `shellAuthentication`. Copilot registers the SDK's `onShellAuthenticationRequest` handler only when that root setting is on; when it's off, sessions behave as they did before this change. The host default is off, so a host that doesn't receive VS Code's settings keeps its current behavior and system prompt. That also keeps the Copilot prompt snapshots of the Agent Host E2E unchanged: registering the handler in every session added the SDK's `sudo -A` guidance to them.
A pending question renders above the chat input, outside the response markdown where chat.css lowers inline icons, so the 16px lock sat 3px above the 13px disclosure text. Give icons in a question's detailed message the same `position: relative; top: 2px`.
Remote and web windows connect through EditorRemoteAgentHostServiceClient, which did not forward answerShellAuthentication. Those windows showed the question, then cancelled the prompt after the user typed the answer.
Web PubSub and Mission Control relays only carry sealed credentials, but shell authentication answers are sent unsealed. Over those connections, and over any connection that cannot deliver an answer, VS Code now shows a question that only cancels the prompt instead of an input whose answer would cross the relay or be dropped. The relay transport also refuses to publish a request that carries an answer, next to its existing refusal of plaintext authentication.
The command was an inline code span in theme-icon Markdown. A blank line, as in a heredoc, ended the span, so the rest of the command rendered as Markdown, and theme icon handling rewrote `$(whoami)` even inside code, leaving a stray backslash. The command now renders in a code block in the question's message, which does not support theme icons, while the notice next to the answer keeps its icon.
The shell authentication notice and setting said every answer isn't saved in the chat, but a user name or a yes/no answer shows in the answered question, so Export Chat can include it. Only masked secrets keep that claim; other answers say only that they aren't sent to the model.
When a turn ended while a prompt was still open, for example when it failed or a steering message became its own turn, the question closed with the turn but the host kept the prompt pending, so the program waited until the prompt timed out. The host now cancels these prompts when the turn ends, as it does for Computer Use.
Resolve the conflict in chat.shared.contribution.ts by importing both CopilotSecurityReviewSecretDetectionEnabledSettingId from main (#348068) and AgentHostCopilotShellAuthenticationEnabledSettingId from this branch.
The card used three styles at once: the command was a monospace code block, the prompt was small muted text, and the notice was larger body text whose paragraph margins left a wide gap above the answer. Add two plain-text question fields, context and note, which the question carousel renders as text rather than Markdown. Shell authentication questions now put the command in context, keep the prompt in the description, and put the notice in a small note with its icon just above the answer, all in the same small muted font. A command still shows exactly as written, including $(whoami), blank lines, and text that looks like Markdown. The note's icon is decorative, so it is hidden from screen readers. Remove the inline icon rule that only this card needed.
…nswer Passwords and passphrases said the answer isn't sent to the model or saved in the chat, while user names and yes/no answers said only that it isn't sent to the model. Every prompt now says the same thing: the answer goes only to the program and isn't sent to the model. The setting description drops the extra sentence too. Secrets are still masked in the input and in the answered question.
Anthony Kim (anthonykim1)
marked this pull request as ready for review
November 13, 2026 09:38
Anthony Kim (anthonykim1)
enabled auto-merge (squash)
November 13, 2026 09:44
Alex Ross (alexr00)
approved these changes
Nov 13, 2026
Anthony Kim (anthonykim1)
deleted the
anthonykim1/agent-host-shell-auth-prompt
branch
November 13, 2026 09:59
3 tasks done
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.


Resolves: #341462
onShellAuthenticationRequesthandler whenchat.agentHost.copilot.shellAuthentication.enabledis on (experimental, on by default; the host's ownshellAuthenticationdefault is off), so password, passphrase, and yes/no prompts fromsudo -A,ssh, andgitbecome a question in chat. With it off, sessions behave as before, including their system prompt.vscode/answerShellAuthenticationrequest instead ofchat/inputCompleted, so it never enters chat state. Local, remote, and web windows forward it to their host, the AHP JSONL log redacts it, and the transcript shows secrets as••••••••._meta, so the Agent Host Protocol doesn't change. Clients that don't recognize it see a single "Cancel Prompt" choice, and anychat/inputCompletedfor it cancels the prompt.passwordflag to question carousels (masked input, no drafts, masked answers; voice skips them) and plain-textcontextandnotefields that never render as Markdown. Wrap long words in descriptions, and document the request and setting insrc/vs/platform/agentHost/AGENTS.md.Screenshots
ssh host key confirmation:
Masked ssh passphrase:
git user name:
A sudo heredoc, shown exactly as written:
Relay connection, cancel only (a local window made to report Mission Control):
Remote window (
vscode-test-resolver) at the default chat width:How to test
sudo -A true,git -c credential.helper= clone <url>for a repo that needs credentials, orsshto a host not inknown_hosts, then answer the question. The command continues, and secrets show as••••••••.vscode-test-resolver), the answer reaches the remote command.Validation
node_modules/.bin/tsc --project ./src/tsconfig.json --noEmit --skipLibCheck,node build/hygiene.ts,node build/oxlint.ts,node build/stylelint.ts, and the layer checkers: passed../scripts/test.shon the 20 affected suites: 9020 passing, 0 failing../scripts/test-integration.sh --only-node-tests: 925 passing, 0 failing; the Copilot prompt snapshots are unchanged.@github/copilot-sdk1.0.32-preview.3: git and ssh answered, sudo cancelled, Stop, a simulated relay, and the setting off in a local window, and git answered in avscode-test-resolverremote window. The fake password appears in none of the files the runs wrote.Inspirations from
vscode/answerShellAuthenticationfollowsvscode/stopBackgroundWork: its declaration, handler, routing, and client forwarder.getAgentHostTcpSupport, and the transport's refusal sits next to its plaintextauthenticaterefusal._metacard follows the Computer Use activation card, and the turn-end cancel follows its_clearActiveTurncancel.contextandnoterender as text like the description and reuse its style; the note's icon isaria-hiddenlike the answer summary icon.allowFreeformInput, and answer redaction follows the logger'spasswordredaction.includeCoAuthoredByand itscoauthorEnabledread, and the host default off follows Move Chats.