Skip to content

Agent Host: Use SDK shell exit metadata for command decorations#323922

Merged
anthonykim1 merged 3 commits into
mainfrom
anthonykim1/commandDecorationFromSDK
Jul 1, 2026
Merged

Agent Host: Use SDK shell exit metadata for command decorations#323922
anthonykim1 merged 3 commits into
mainfrom
anthonykim1/commandDecorationFromSDK

Conversation

@anthonykim1

@anthonykim1 anthonykim1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Resolves: #322163
Context: github/copilot-sdk#1803

You will now see proper command decoration when using shell tool from SDK:
Screenshot 2026-07-01 at 2 05 21 PM

  • Add shell_exit as Agent Host tool result content for SDK shell command exit metadata.
  • Preserve SDK tool.execution_complete.result.contents[] shell exit blocks in both live Copilot Agent Host events and replay/history mapping.
  • Use shell_exit.exitCode as the terminal command state source when the custom terminal tool is disabled.
  • Treat exitCode === 0 as success, non-zero exit codes as failure, and missing shell exit metadata as unknown/compatibility fallback.
  • Keep result.content as the displayed text output and avoid rendering shell_exit.outputPreview as duplicate terminal output.
  • Do not create fake terminal URI/resource content for SDK shell exit metadata.

Inspirations from:

  • Terminal command decoration state follows existing chat terminal behavior where exitCode === undefined means unfinished and non-zero exit codes are failures: chatTerminalToolProgressPart.ts.
Copilot AI review requested due to automatic review settings July 1, 2026 18:52
@anthonykim1 anthonykim1 self-assigned this Jul 1, 2026
@anthonykim1 anthonykim1 added this to the 1.128.0 milestone Jul 1, 2026
@anthonykim1 anthonykim1 marked this pull request as ready for review July 1, 2026 18:55

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.

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 corresponding ToolResultShellExitContent type.
  • Preserves SDK tool.execution_complete.result.contents[] blocks (specifically shell_exit) when mapping both live session events and replay/history.
  • Updates the chat-side terminal tool mapping to prefer shell_exit.exitCode over SDK success when computing terminalCommandState.exitCode (with tests covering non-zero exit codes even when success: 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
@anthonykim1 anthonykim1 marked this pull request as draft July 1, 2026 18:58
@anthonykim1 anthonykim1 marked this pull request as ready for review July 1, 2026 21:07
@anthonykim1 anthonykim1 merged commit d892b57 into main Jul 1, 2026
29 checks passed
@anthonykim1 anthonykim1 deleted the anthonykim1/commandDecorationFromSDK branch July 1, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants