Skip to content

Adapt onShellAuthenticationRequest for sudo, ssh, and git passwords in chat - #348067

Merged
Anthony Kim (anthonykim1) merged 13 commits into
mainfrom
anthonykim1/agent-host-shell-auth-prompt
Nov 13, 2026
Merged

Anthony Kim (anthonykim1) merged 13 commits into
mainfrom
anthonykim1/agent-host-shell-auth-prompt

Conversation

@anthonykim1

@anthonykim1 Anthony Kim (anthonykim1) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Resolves: #341462

  • Register the Copilot SDK's onShellAuthenticationRequest handler when chat.agentHost.copilot.shellAuthentication.enabled is on (experimental, on by default; the host's own shellAuthentication default is off), so password, passphrase, and yes/no prompts from sudo -A, ssh, and git become a question in chat. With it off, sessions behave as before, including their system prompt.
  • Show the command as written, the program's prompt, and a note that the answer goes only to that program and isn't sent to the model. Secrets use a masked input.
  • Send the answer with a new VS Code-only vscode/answerShellAuthentication request instead of chat/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 ••••••••.
  • Over Web PubSub and Mission Control relays, which carry only sealed credentials, and over any connection that can't deliver the answer, the question can only cancel the prompt. The relay transport also refuses to publish an answer.
  • Carry the prompt in the input request's _meta, so the Agent Host Protocol doesn't change. Clients that don't recognize it see a single "Cancel Prompt" choice, and any chat/inputCompleted for it cancels the prompt.
  • Cancel the prompt in Autopilot, with auto-reply, with no active turn, on Stop, when the turn ends, and when the SDK no longer needs the answer.
  • Add a password flag to question carousels (masked input, no drafts, masked answers; voice skips them) and plain-text context and note fields that never render as Markdown. Wrap long words in descriptions, and document the request and setting in src/vs/platform/agentHost/AGENTS.md.
Screenshots

ssh host key confirmation:

ssh host key confirmation in chat

Masked ssh passphrase:

masked ssh passphrase input

git user name:

git user name question

A sudo heredoc, shown exactly as written:

sudo heredoc command in the question

Relay connection, cancel only (a local window made to report Mission Control):

cancel-only question over a relay

Remote window (vscode-test-resolver) at the default chat width:

git user name question in a remote window

How to test
  1. Ask the agent to run sudo -A true, git -c credential.helper= clone <url> for a repo that needs credentials, or ssh to a host not in known_hosts, then answer the question. The command continues, and secrets show as ••••••••.
  2. Escape cancels the prompt; Stop closes the question as skipped.
  3. In a remote window (Remote-SSH or vscode-test-resolver), the answer reaches the remote command.
  4. With the setting off, the same clone fails without a question, as before.
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.sh on 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.
  • Code OSS with the bundled @github/copilot-sdk 1.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 a vscode-test-resolver remote window. The fake password appears in none of the files the runs wrote.
Inspirations from

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.
@anthonykim1
Anthony Kim (anthonykim1) marked this pull request as ready for review November 13, 2026 09:38
@anthonykim1 Anthony Kim (anthonykim1) changed the title agentHost: ask for sudo, ssh, and git passwords in chat Adapt onShellAuthenticationRequest for sudo, ssh, and git passwords in chat Nov 13, 2026
@anthonykim1
Anthony Kim (anthonykim1) merged commit 9d3e156 into main Nov 13, 2026
52 of 53 checks passed
@anthonykim1
Anthony Kim (anthonykim1) deleted the anthonykim1/agent-host-shell-auth-prompt branch November 13, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Copilot CLI (Copilot SDK) agent sessions can't use visible VS Code terminals, so the user can't complete interactive auth (SSH/sudo passwords)

3 participants