Agent Host: Use SDK shell exit metadata for command decorations#323922
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Agent Host ↔ Chat workbench integration so terminal command decorations can reflect the actual shell exit code provided by the Copilot SDK (shell_exit), including in both live event handling and history replay.
Changes:
- Adds a new
ToolResultContentType.ShellExit(shell_exit) content block and correspondingToolResultShellExitContenttype. - Preserves SDK
tool.execution_complete.result.contents[]blocks (specificallyshell_exit) when mapping both live session events and replay/history. - Updates the chat-side terminal tool mapping to prefer
shell_exit.exitCodeover SDKsuccesswhen computingterminalCommandState.exitCode(with tests covering non-zero exit codes even whensuccess: true).
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts | Uses shell_exit.exitCode to drive terminalCommandState.exitCode for terminal tool invocations/serialization. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts | Adds tests verifying shell_exit exit codes are used for history and finalize behavior. |
| src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts | Appends SDK shell_exit typed blocks into tool-result content during replay mapping. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Appends SDK shell_exit typed blocks for live tool.execution_complete handling. |
| src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts | Adds replay tests ensuring shell_exit is preserved (including non-zero exit codes). |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Adds live-event test ensuring shell_exit is preserved in tool completion results. |
| src/vs/platform/agentHost/test/node/copilotTestEvents.ts | Extends minimal SDK test event shapes to include result.contents. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Re-exports ToolResultShellExitContent from the protocol state barrel. |
| src/vs/platform/agentHost/common/state/protocol/channels-chat/state.ts | Adds ToolResultContentType.ShellExit and ToolResultShellExitContent to the protocol model. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 2
- Review effort level: Low
pwang347
approved these changes
Jul 1, 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.
Resolves: #322163
Context: github/copilot-sdk#1803
You will now see proper command decoration when using shell tool from SDK:

shell_exitas Agent Host tool result content for SDK shell command exit metadata.tool.execution_complete.result.contents[]shell exit blocks in both live Copilot Agent Host events and replay/history mapping.shell_exit.exitCodeas the terminal command state source when the custom terminal tool is disabled.exitCode === 0as success, non-zero exit codes as failure, and missing shell exit metadata as unknown/compatibility fallback.result.contentas the displayed text output and avoid renderingshell_exit.outputPreviewas duplicate terminal output.Inspirations from:
exitCode === undefinedmeans unfinished and non-zero exit codes are failures:chatTerminalToolProgressPart.ts.