Skip to content

Don't send background notifications to main agent when subagent is used#308836

Open
meganrogge wants to merge 1 commit intomainfrom
merogge/subagent-skip
Open

Don't send background notifications to main agent when subagent is used#308836
meganrogge wants to merge 1 commit intomainfrom
merogge/subagent-skip

Conversation

@meganrogge
Copy link
Copy Markdown
Collaborator

fix #308048

The subagent only had access to run_in_terminal — it couldn't check output, send input, or kill terminals. We've added access to those tools for the subagent microsoft/vscode-copilot-chat#5050.

Background terminal completion notifications were sent to the parent session, which had no context for them. When it's a subagent, we no longer do this.

Copilot AI review requested due to automatic review settings April 9, 2026 17:37
@meganrogge meganrogge self-assigned this Apr 9, 2026
@meganrogge meganrogge added this to the 1.116.0 milestone Apr 9, 2026
@meganrogge meganrogge enabled auto-merge (squash) April 9, 2026 17:37
@meganrogge meganrogge requested a review from vikramnitin9 April 9, 2026 17:37
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

Adjusts terminal tool background-notification behavior to avoid sending “background command completed” steering messages to the parent chat session when the terminal was started by a subagent (which lacks the context/tool loop to act on that notification).

Changes:

  • Gate background completion notifications on !invocation.subAgentInvocationId to suppress steering messages for subagent-initiated background terminals.
  • Update inline comments to document why subagent background notifications are skipped and how subagents should retrieve output.
Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts Suppresses background terminal completion steering notifications for subagent tool invocations.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:1403

  • This introduces new behavior that disables background completion notifications when invocation.subAgentInvocationId is set. Given the existing comprehensive RunInTerminalTool test suite, it would be good to add coverage asserting that subagent invocations do not register a background notification / steering message (and that the tool’s returned text doesn’t claim a notification will arrive).
				// Skip notifications for subagent-initiated terminals: the subagent runs in its
				// own tool calling loop and cannot receive steering messages. It can poll with
				// get_terminal_output instead.
				if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.BackgroundNotifications) && !invocation.subAgentInvocationId) {
					this._registerCompletionNotification(toolTerminal.instance, termId, chatSessionResource, command, outputMonitor);
  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +1398 to 1403
// background terminal, and continue the output monitor for prompt-for-input detection.
// Skip notifications for subagent-initiated terminals: the subagent runs in its
// own tool calling loop and cannot receive steering messages. It can poll with
// get_terminal_output instead.
if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.BackgroundNotifications) && !invocation.subAgentInvocationId) {
this._registerCompletionNotification(toolTerminal.instance, termId, chatSessionResource, command, outputMonitor);
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

With this change, subagent-initiated background terminals will no longer trigger steering notifications, but other parts of this tool still tell the model it will be “automatically notified” when chat.tools.terminal.backgroundNotifications is enabled (e.g. the timeout hint around notificationHint and the tool/model descriptions). That becomes incorrect for subagent invocations and can cause the subagent to wait/assume a notification that never arrives. Consider centralizing a shouldSendBackgroundNotifications = configEnabled && !invocation.subAgentInvocationId flag and using it both here and anywhere we generate those “you will be notified” hints (or wording them so they don’t promise notifications in subagent context).

This issue also appears on line 1399 of the same file.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

execution subagent doesn't work with new async terminal stuff

2 participants