Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

fixes #291871

Description

Agent-executed terminal commands reported exit code 130 (SIGINT) despite succeeding. Commands completed successfully (e.g., git commit created commits, echo $? showed 0), but agents received exit code 130.

Root causes:

  1. Input tracking used wrong event: Listened to onData (all terminal data) instead of onDidInputData (input only), causing command output to set receivedUserInput = true

  2. Listener timing issue: onCommandFinished listener was set up before SIGINT was sent. When SIGINT executed (triggered by false positive from Open Source VS Code #1), it fired onCommandFinished with exit 130, resolving the completion promise. Actual command then executed successfully, but exit code already captured as 130.

Changes:

  • runInTerminalTool.ts: Changed input listener from onData to onDidInputData
  • basicExecuteStrategy.ts: Moved onCommandFinished listener setup to after command execution
// Before: listener set up before command
const onDone = Promise.race([
  Event.toPromise(this._commandDetection.onCommandFinished, ...)
]);
await this._instance.sendText('\x03', false);  // SIGINT fires onCommandFinished → exit 130
this._instance.sendText(commandLine, true);    // Actual command succeeds but exit code already captured

// After: listener set up after command
await this._instance.sendText('\x03', false);
this._instance.sendText(commandLine, true);
const onDone = Promise.race([
  Event.toPromise(this._commandDetection.onCommandFinished, ...)  // Now captures actual command
]);
Original prompt

Terminal runs especially within thinking block by an agent are being interpreted as the command exits with code 130 despite double checking within the terminal by running echo $? I see exit code 0 -- I also see the effect of the command run, e.g., if git commit was run then the commit does exist, but agent thinks it exited with 130.

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md
  • AGENTS.md

Created from VS Code.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Changed input listener from onData to onDidInputData to avoid treating command output as user input
- Moved onCommandFinished listener setup to after command execution to prevent capturing SIGINT exit code (130) instead of actual command exit code
- The issue was that onDone promise was set up before SIGINT, so SIGINT's onCommandFinished event (exit 130) was captured instead of the actual command's exit code

Co-authored-by: ulugbekna <16353531+ulugbekna@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix agent interpreting command exit code as 130 Fix terminal commands incorrectly reporting exit code 130 Jan 30, 2026
Copilot AI requested a review from ulugbekna January 30, 2026 12:08
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.

Agent running terminal commands often things command exited with code 130 while it succeeded and exited with 0

2 participants