Skip to content

Fix terminal tool output truncation #302884

Draft
meganrogge wants to merge 3 commits intomainfrom
merogge/wait-terminal
Draft

Fix terminal tool output truncation #302884
meganrogge wants to merge 3 commits intomainfrom
merogge/wait-terminal

Conversation

@meganrogge
Copy link
Collaborator

fix #297109

NOTE I COULD NOT REPRO THIS ON MAC, need to test on Windows

This fixes non-deterministic output truncation in terminal chat tool execution.

  1. Added command-id matching for command-finished events in rich/basic execute strategies so unrelated finish events are ignored.
  2. Added a short output-flush wait before creating the end marker to reduce race conditions where final lines were not yet captured.
  3. Reused shared helpers for both behaviors to keep strategy logic consistent.
  4. Added targeted unit tests for command-id matching behavior.

Terminal command output capture is more reliable, especially for the final lines of command output, and less susceptible to event timing races.

Copilot AI review requested due to automatic review settings March 18, 2026 16:17
@meganrogge meganrogge marked this pull request as draft March 18, 2026 16:17
@meganrogge meganrogge requested a review from Tyriar March 18, 2026 16:17
@meganrogge meganrogge changed the title Ftool output truncation by waiting for output flush and matching command-finished events by command id Fix terminal tool output truncation Mar 18, 2026
@meganrogge meganrogge self-assigned this Mar 18, 2026
@meganrogge meganrogge added this to the 1.114.0 milestone Mar 18, 2026
Copy link
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

Improves reliability of run_in_terminal output capture in the terminal chat agent tools by reducing timing races at command completion and by ensuring onCommandFinished events are correlated to the intended command via command IDs.

Changes:

  • Filter onCommandFinished events by requested commandId in rich/basic execute strategies to ignore unrelated finish events.
  • Add a short “output flush” wait before placing the end marker to reduce last-line truncation races.
  • Add unit tests for the new command-id matching helper.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.ts Adds shared helpers for command-id matching and brief output-flush waiting.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.ts Filters command-finished events by id and waits briefly before registering end marker.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.ts Filters command-finished events by id and waits briefly before registering end marker.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts Waits briefly before registering end marker to reduce truncation races.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/executeStrategy.test.ts Adds tests for commandMatchesRequestedId.

meganrogge and others added 2 commits March 18, 2026 12:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Bug Report: run_in_terminal tool non-deterministically truncates command output

2 participants