Skip to content

Agent Host Copilot CLI: Support async shell completion notifications#318511

Merged
anthonykim1 merged 5 commits into
mainfrom
anthonykim1/agentHostAsyncShell
May 30, 2026
Merged

Agent Host Copilot CLI: Support async shell completion notifications#318511
anthonykim1 merged 5 commits into
mainfrom
anthonykim1/agentHostAsyncShell

Conversation

@anthonykim1
Copy link
Copy Markdown
Contributor

@anthonykim1 anthonykim1 commented May 27, 2026

Resolves: #318505
Related: #312178

  • Listen for Copilot SDK system.notification events from Agent Host Copilot sessions when the custom terminal tool is disabled and the SDK native shell tool is in use.
  • Translate SDK shell/background-agent completion notifications into Agent Host system notifications, covering shell_completed, shell_detached_completed, and agent_completed.
  • Start a system-initiated Agent Host turn when the session is idle, without sending another SDK message; the runtime already queued the follow-up work.
  • Reuse SystemNotificationResponsePart when a notification arrives during an active turn, so in-turn notifications do not create duplicate turns.
  • Carry the compact system-initiated label through Agent Host turn state, chat session server-request plumbing, restored history, and progress adaptation.
  • Clear completed Agent Host turn state on session.idle so later async completions do not attach to a stale turn.

Before:
before

After:
Screenshot 2026-05-28 at 2 58 03 PM


Inspirations from:

@anthonykim1 anthonykim1 added this to the 1.123.0 milestone May 27, 2026
@anthonykim1 anthonykim1 self-assigned this May 27, 2026
Copilot AI review requested due to automatic review settings May 27, 2026 05:17
@anthonykim1 anthonykim1 moved this to In Progress in Agent Host Protocol May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds Copilot Agent Host support for async system.notification events so shell/background completions can appear in chat even when they arrive outside the normal request/response flow.

Changes:

  • Adds Copilot SDK notification plumbing and translation for supported system notification kinds.
  • Threads system-initiated turn metadata through agent-host protocol state and chat session/model history.
  • Restores system notifications as chat progress messages and adds tests for notification turn/progress behavior.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts Updates fake session event typing for server-initiated request metadata.
src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts Adds tests for system-initiated history and notification progress conversion.
src/vs/workbench/contrib/chat/common/chatSessionsService.ts Extends chat session request/history types with system-initiated metadata.
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts Preserves system-initiated fields when creating chat model requests.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts Converts agent-host system notification response parts to chat progress messages.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Propagates system-initiated labels through active/restored agent-host sessions.
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Adds Copilot system notification translation and lifecycle tests.
src/vs/platform/agentHost/node/copilot/copilotSystemNotification.ts Introduces notification content cleanup and supported-kind label mapping.
src/vs/platform/agentHost/node/copilot/copilotSessionWrapper.ts Exposes the Copilot SDK system.notification event.
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Handles notifications by appending to active turns or synthesizing system-initiated turns.
src/vs/platform/agentHost/common/state/protocol/channels-session/state.ts Adds system-initiated labels to turn state.
src/vs/platform/agentHost/common/state/protocol/channels-session/reducer.ts Carries system-initiated labels through active and completed turns.
src/vs/platform/agentHost/common/state/protocol/channels-session/actions.ts Adds system-initiated labels to turn-start actions.

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 0

@anthonykim1 anthonykim1 marked this pull request as ready for review May 27, 2026 06:32
@anthonykim1 anthonykim1 changed the title Agent Host Copilot CLI) Support async shell completions Agent Host Copilot CLI: Support async shell completion notifications May 27, 2026
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Outdated
/** User's message */
userMessage: UserMessage;
/** Display label for a system-initiated turn. */
systemInitiatedLabel?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make sure these get upstreamed in the protocol

Copy link
Copy Markdown
Contributor Author

@anthonykim1 anthonykim1 May 27, 2026

Choose a reason for hiding this comment

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

Incoming: microsoft/agent-host-protocol#150

Adopting again since we're going with: microsoft/agent-host-protocol#155

connor4312
connor4312 previously approved these changes May 27, 2026
@connor4312
Copy link
Copy Markdown
Member

I'm suggest probably resetting before f65ffe9 and merging origin/main first, which adopts the customizations and should reduce your conflicts

@anthonykim1 anthonykim1 force-pushed the anthonykim1/agentHostAsyncShell branch from f65ffe9 to a7b4d47 Compare May 28, 2026 21:53
connor4312
connor4312 previously approved these changes May 28, 2026
}

this._logService.info(`[Copilot:${sessionId}] System notification received: kind=${e.data.kind.type}`);
if (this._turnId) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this, what kind of system notification is this that becomes part of the response?

Copy link
Copy Markdown
Contributor Author

@anthonykim1 anthonykim1 May 28, 2026

Choose a reason for hiding this comment

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

These are SDK system.notification events, which are:
a background shell finishing (SystemNotificationShellCompleted / SystemNotificationShellDetachedCompleted) or a background agent finishing (SystemNotificationAgentCompleted). When one arrives mid-turn we attach it as part of the current response.

roblourens
roblourens previously approved these changes May 28, 2026
@anthonykim1 anthonykim1 dismissed stale reviews from roblourens and connor4312 via 5a4c6d5 May 29, 2026 20:41
@anthonykim1 anthonykim1 force-pushed the anthonykim1/agentHostAsyncShell branch from a7b4d47 to 5a4c6d5 Compare May 29, 2026 20:41
@anthonykim1 anthonykim1 marked this pull request as ready for review May 29, 2026 20:45
connor4312
connor4312 previously approved these changes May 29, 2026
@anthonykim1 anthonykim1 marked this pull request as draft May 29, 2026 21:35
@anthonykim1 anthonykim1 marked this pull request as ready for review May 29, 2026 21:38
justschen
justschen previously approved these changes May 29, 2026
roblourens
roblourens previously approved these changes May 29, 2026
@anthonykim1 anthonykim1 marked this pull request as draft May 29, 2026 23:30
@anthonykim1 anthonykim1 dismissed stale reviews from roblourens and justschen via ec98bc9 May 29, 2026 23:36
@anthonykim1 anthonykim1 marked this pull request as ready for review May 29, 2026 23:36
@anthonykim1 anthonykim1 marked this pull request as draft May 29, 2026 23:40
@anthonykim1 anthonykim1 marked this pull request as ready for review May 29, 2026 23:46
*/
export const SUPPORTED_PROTOCOL_VERSIONS: readonly string[] = Object.freeze([
PROTOCOL_VERSION,
'0.3.0',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is the constant not referenced here?

Copy link
Copy Markdown
Contributor Author

@anthonykim1 anthonykim1 May 29, 2026

Choose a reason for hiding this comment

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

ah, good point. I think it might have to come from upstream first though. Let me go file issue / tackle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Agent host Copilot CLI) Support async shell tool experience

6 participants