Skip to content

Skip redundant steering message when kill_terminal disposes terminal#314130

Merged
meganrogge merged 1 commit intomainfrom
meganrogge/fix-kill-terminal-steering
May 4, 2026
Merged

Skip redundant steering message when kill_terminal disposes terminal#314130
meganrogge merged 1 commit intomainfrom
meganrogge/fix-kill-terminal-steering

Conversation

@meganrogge
Copy link
Copy Markdown
Collaborator

@meganrogge meganrogge commented May 4, 2026

When the agent calls kill_terminal on a backgrounded terminal, the onDisposed handler in _registerCompletionNotification fires and sends a redundant "terminal exited" steering message. This disrupts the tool-result processing loop, causing the agent to stop responding — found in 5/89 terminalbench2 eval tests.

Fixes microsoft/vscode-internalbacklog#7606

Copilot AI review requested due to automatic review settings May 4, 2026 15:45
@meganrogge meganrogge self-assigned this May 4, 2026
@meganrogge meganrogge force-pushed the meganrogge/fix-kill-terminal-steering branch from 4bb928a to a681c68 Compare May 4, 2026 15:47
@meganrogge meganrogge added this to the 1.120.0 milestone May 4, 2026
@meganrogge
Copy link
Copy Markdown
Collaborator Author

/requires-eval-assessment terminalbench2 gpt-5.4,claude-opus-4.6,claude-opus-4.7

@vs-code-engineering vs-code-engineering Bot added the ~requires-eval-assessment Evals will be run and will generate a report upon completion label May 4, 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 aims to prevent duplicate “terminal exited” steering notifications when a background terminal is terminated via the kill_terminal tool, relying on kill_terminal’s tool result as the single source of final output.

Changes:

  • In runInTerminalTool, adds a guard in the terminal onDisposed handler to skip sending a steering message when the execution is no longer tracked.
  • In killTerminalTool, removes the tracked execution before disposing the terminal instance so the onDisposed handler observes it as already removed.
  • Updates inline comments to document the intended interaction between kill_terminal and background completion notifications.
Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts Adds an onDisposed early-return intended to suppress redundant steering notifications after kill_terminal.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/killTerminalTool.ts Reorders cleanup to remove execution tracking before disposing the terminal, to influence onDisposed behavior.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

When the agent calls kill_terminal, the onDisposed handler in
_registerCompletionNotification fires and sends a redundant steering
message that disrupts the tool-result processing loop.

Fix by adding a dedicated _killedByTool set that kill_terminal marks
before disposing the terminal. The onDisposed handler checks this set
and skips the steering message when present. This avoids relying on
_activeExecutions membership which can be removed by other cleanup
paths (e.g. _removeExecutionAssociations from onDidDisposeInstance).

The steering message still fires for user-initiated terminal closes
and natural process exits.

Fixes microsoft/vscode-internalbacklog#7606

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@meganrogge meganrogge force-pushed the meganrogge/fix-kill-terminal-steering branch from a681c68 to 7c327f3 Compare May 4, 2026 16:15
@meganrogge meganrogge added ~requires-eval-assessment Evals will be run and will generate a report upon completion and removed ~requires-eval-assessment Evals will be run and will generate a report upon completion labels May 4, 2026
@meganrogge meganrogge enabled auto-merge (squash) May 4, 2026 16:23
@vs-code-engineering
Copy link
Copy Markdown
Contributor

⏳ Queued vscode build for 7c327f35f75e98d4f3106744d31b58f0959fe6f4 (step 1/2).

@meganrogge meganrogge merged commit b320e7e into main May 4, 2026
26 checks passed
@meganrogge meganrogge deleted the meganrogge/fix-kill-terminal-steering branch May 4, 2026 16:32
@vs-code-engineering
Copy link
Copy Markdown
Contributor

🚀 Queued eval-assessment publish build for 22c2fe60d4e1eed96fb752b387d13be3f1c66fe3 (step 2/2).

@vs-code-engineering
Copy link
Copy Markdown
Contributor

🔬 Queued eval-assessment benchmark for 54992fecee.

Results will be posted back here when the run completes.

@vs-code-engineering
Copy link
Copy Markdown
Contributor

✅ Eval-assessment build published.

@vs-code-engineering vs-code-engineering Bot removed the ~requires-eval-assessment Evals will be run and will generate a report upon completion label May 4, 2026
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📊 Eval-assessment benchmark complete.

Analysis Results

Resolution Rate

Benchmark Total Cases Passed Failed Resolved Rate
terminalbench2 89 37 52 41.57%

Token Usage

Metric Value
Total Tokens 28,097,062
Input Tokens 27,547,236
Output Tokens 549,826
Cached Tokens 23,479,936

Step Counts

Metric Value
Total Steps 853
Mean Steps/Instance 9.58

@vs-code-engineering
Copy link
Copy Markdown
Contributor

📊 Eval-assessment benchmark complete.

Analysis Results

Resolution Rate

Benchmark Total Cases Passed Failed Resolved Rate
terminalbench2 89 34 55 38.20%

Token Usage

Metric Value
Total Tokens 32,648,643
Input Tokens 32,046,429
Output Tokens 602,214
Cached Tokens 30,358,592

Step Counts

Metric Value
Total Steps 765
Mean Steps/Instance 8.60

@vs-code-engineering
Copy link
Copy Markdown
Contributor

📊 Eval-assessment benchmark complete.

Analysis Results

Resolution Rate

Benchmark Total Cases Passed Failed Resolved Rate
terminalbench2 89 31 58 34.83%

Token Usage

Metric Value
Total Tokens 40,283,618
Input Tokens 39,506,783
Output Tokens 776,835
Cached Tokens 37,215,984

Step Counts

Metric Value
Total Steps 1,071
Mean Steps/Instance 12.03

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.

3 participants