Set TERM_PROGRAM for Agent Host terminals created by VS Code clients - #338612
Merged
Anthony Kim (anthonykim1) merged 4 commits intoSep 29, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Anthony Kim (anthonykim1)
September 29, 2026 04:45
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is scoped, backward-compatible, and comprehensively covers the stated terminal lifecycle cases.
Review effort: Balanced
Findings: None
What changed in this PR
Adds client-specific terminal identity metadata so newly created Agent Host terminals receive the correct TERM_PROGRAM values without affecting existing or non-VS Code terminals.
Changes:
- Sends validated terminal identity metadata during creation.
- Applies identity variables while preserving unmarked terminal environments.
- Adds coverage for creation, attachment, reconnection, validation, and alternate clients.
| File | Description |
|---|---|
agentHostTerminalService.test.ts |
Tests VS Code client identity metadata. |
agentHostPty.test.ts |
Tests creation, attachment, and reconnection behavior. |
agentHostTerminalService.ts |
Supplies the client product version. |
agentHostPty.ts |
Adds identity metadata to creation requests. |
agentHostTerminalManager.test.ts |
Tests validation and environment handling. |
agentHostTerminalManager.ts |
Applies requested identity to spawned terminals. |
agentTerminalMeta.ts |
Defines metadata serialization and validation. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the VS Code-specific createTerminal metadata with the client identity the host already receives at initialize. createTerminal now forwards the requesting connection's client context, and terminals created by VS Code clients get TERM_PROGRAM=vscode and the host's TERM_PROGRAM_VERSION. Other clients, attachments, and tool shells keep the inherited environment.
createTerminal only needs to know whether a VS Code client made the request, so take AgentHostClientType instead of the full client telemetry context.
Anthony Kim (anthonykim1)
marked this pull request as ready for review
September 29, 2026 06:01
Anthony Kim (anthonykim1)
enabled auto-merge (squash)
September 29, 2026 06:02
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 29, 2026
Anthony Kim (anthonykim1)
deleted the
anthonykim1/agent-host-terminal-identifier
branch
September 29, 2026 06:22
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: #338608
vscodeTerminalIdentityoption toAgentHostTerminalManager.createTerminalthat setsTERM_PROGRAM=vscodeandTERM_PROGRAM_VERSIONto the agent host's product version.AgentHostClientTypefrom thecreateTerminalprotocol handler toIAgentService.createTerminal.clientInfoatinitialize.!commands, which call the terminal manager directly.Validation
npm run transpile-client,agentHostTerminalManager.test.tsandprotocolServerHandler.test.tspass (192 tests), both withTERM_PROGRAM/TERM_PROGRAM_VERSIONunset and with conflicting inherited values.Manual test
printf 'TERM_PROGRAM=%s\nTERM_PROGRAM_VERSION=%s\n' "$TERM_PROGRAM" "$TERM_PROGRAM_VERSION".vscodeand the build's version.echo "$TERM_PROGRAM"and verify the tool shell keeps the inherited value.Inspirations from:
addTerminalEnvironmentKeys. Only the identity is shared, not the full workbench environment or extension-collection pipeline.vscodeTerminalIdentityoption shape and placement follow the existing per-requestpreventShellHistoryandnonInteractiveenvironment options inAgentHostTerminalManager.createTerminal.dispatchActionpassesclient.telemetryContexttoIAgentService.dispatchAction. Only itsclientTypeis passed here, since terminal creation needs nothing else.getAgentHostClientType.RemoteTerminalChannel, which passes the server'sproductService.versionwhen creating remote terminals.session working-directory actions reach the agent service.