Copilot does not detect terminal command has completed or is not getting terminal output #161238
-
Select Topic AreaBug Copilot Feature AreaGeneral BodyWhen using Copilot Agent, it requests to run terminal commands, but it sometimes does not get the terminal output. The executed command produced output, but the agent thinks nothing was given. The agent then starts going down a path to discover what is wrong, assuming it has done something wrong. This results in the agent using context space on things it didn't need to do. It also puts the agent in a weird state where it can modify and undo correct code it had written before, thinking it caused a problem that needed to be reverted. There is another situation where the terminal command completes, and I see the output, but the agent is still waiting for the command to complete. It never sees completion and will be in this state for hours. It is not until I press enter in the terminal that helps signal completion, and the agent will continue. But combine this with the missing terminal output, and the agent session gets weird and sidetracked. Combine this with the summarizing context; the agent forgets essential details. I try to restart VSCode or close the terminal but that does not resolve the problem. It might or might not return. I am working with a VSCode instance executed from a WSL terminal. There is another problem where the agent creates a new file and wants to run a command in one response. If I don't notice that a new file was created and click continue to run the command, the file will be in an empty state, which throws the agent off, and it starts going down a debugging path. I have to make sure, before I run any commands, that all files have been "keep" and saved. If these issues are resolved, I believe the agent quality will improve. |
Beta Was this translation helpful? Give feedback.
Replies: 60 comments 78 replies
-
|
When Copilot starts the premium request tracking, this will be a massive problem because I have to use additional requests to work around the failed output. The agent also uses requests to resolve something that is not real. |
Beta Was this translation helpful? Give feedback.
-
|
It ended up zsh problem, switching to bash fixed the problem. shift + cmd + p, type "Terminal: select default profile" choose bash |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for all the details in the comments everyone. I did an investigation into this and the reason it was hard to reproduce is that it only reproduced on old versions of powerlevel10k. For most people, running this will fix the problem and also probably give you new features to play with in p10k: cd ~/powerlevel10k && git pullGoing forward we're making these changes to mitigate this issue:
|
Beta Was this translation helpful? Give feedback.
-
|
I keep hitting this issue. The fact that it keeps retrying when it can't get the content is irritating. |
Beta Was this translation helpful? Give feedback.
-
Investigation Report: GitHub Copilot Cannot Capture Output from Long-Running Terminal CommandsI've conducted a systematic investigation into the issue where GitHub Copilot fails to capture output from certain terminal commands. Here are my findings: Test Environment
Test Results✅ Commands that work correctly:uuidgen -r
# Output: Successfully captured UUID like "795e6cbe-96d0-4551-9f97-c24f4fee2eb6"❌ Commands that fail to capture output:# run go test in docker container
make test-pkg PKG=./my_pkg 2>&1
# run go test command in local
go test -v ./my_pkg
# go build
go build -o /dev/null ./my_pkgThese commands return empty output despite producing substantial terminal output when run manually. ✅ Workaround that works:go test -v ./my_pkg > /tmp/test_output.log 2>&1
# Then reading the file with read_file tool works perfectlyAnalysisThe issue appears to be specifically related to:
Short, simple commands like
ImpactThis significantly limits Copilot's ability to:
Current WorkaroundThe only reliable method is to redirect output to a temporary file and then read it: command_with_complex_output > /tmp/output.log 2>&1
# Then use read_file tool to access /tmp/output.logRequestCould the GitHub Copilot team investigate and improve the terminal command execution tool to handle:
This would greatly enhance Copilot's utility for development workflows and debugging scenarios. |
Beta Was this translation helpful? Give feedback.
-
|
This was the solution cloude gave me, and its working for my specific enviroment ✅ Complete Fix for GitHub Copilot Terminal Completion Detection BugProblem SummaryGitHub Copilot agents fail to detect when terminal commands complete, causing infinite hangs especially with:
Root Causes
Complete Solution (macOS/Linux + ZSH)Step 1: Update Powerlevel10k Themecd ~/.oh-my-zsh/custom/themes/powerlevel10k
git pullVerify update: git log -1 --format="%ai"Should show 2023 or later. Step 2: Update VS Code SettingsAdd these settings to your {
"terminal.integrated.shellIntegration.enabled": true,
"terminal.integrated.shellIntegration.decorationsEnabled": "both",
"terminal.integrated.shellIntegration.showWelcome": false,
"terminal.integrated.commandTimeout": 30000
}What this does:
Step 3: Add Shell Integration to
|
Beta Was this translation helpful? Give feedback.
-
|
I was able to resolve this by removing my ZSH theme (ZSH_THEME="sorin") from my .zshrc. I’d like to re-enable it, but for now the drawbacks outweigh the benefits - so a bug fix would be appreciated! How I confirmed the issue, and how you might find your own cause of the issue: I recommend this approach, as your issue might be related to a different theme or plugin.
|
Beta Was this translation helpful? Give feedback.
-
|
I found that my installation of powerlevel10k in |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Same issue. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @MarkWard0110, I've been facing a similar issue myself, but when running VS Code Tasks. It can run tasks without user interaction, but can't seem to read their output. Do you see any difference if you use VS Code tasks compared to having Github Copilot run CLI commands directly? |
Beta Was this translation helpful? Give feedback.
-
|
I have the same problem. Had to resort to pasting the command myself in the console and continuing the conversation with "#terminalLastCommand" for the agent to get the output. It works, but sometimes confuses the agent which thinks the command was my own an I've been doing something in parallel. |
Beta Was this translation helpful? Give feedback.
-
|
This is happening to me also for both bash/ohmyzsh setups @nhu-do could you flag this thread to the required dev team. Its being lost in the noise and need's support from the dev team |
Beta Was this translation helpful? Give feedback.
-
|
I had the same issue using zsh/oh-my-zsh. But I'm not using powerlevel10k. TL;DR: adding the below snippet to .zshrc fixes the issue (for me at least) Based on the GitHub issue and your theme configuration, the problem is with the right-side prompt (RPS1) in your af-magic.zsh-theme. This is a known issue with VS Code's Copilot terminal integration. The ProblemYour theme defines: RPS1="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
RPS1+='$(virtualenv_prompt_info)'
RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"The RPROMPT (right-side prompt) interferes with VS Code's shell integration, causing Copilot to fail detecting when commands complete. The SolutionAdd VS Code-specific configuration to your # ...existing code...
# VS Code Shell Integration for Copilot
# Fix for terminal completion detection issue
if [[ "$TERM_PROGRAM" == "vscode" ]]; then
# Disable RPROMPT in VS Code (causes detection issues)
unset RPROMPT
unset RPS1
# Load VS Code shell integration
[[ -f "$(code --locate-shell-integration-path zsh)" ]] && \
. "$(code --locate-shell-integration-path zsh)"
fiAlternative: Modify the Theme DirectlyIf you prefer to fix it in the theme itself: # ...existing code...
# right prompt: return code, virtualenv and context (user@host)
# Disable RPS1 in VS Code to fix Copilot command detection
if [[ "$TERM_PROGRAM" != "vscode" ]]; then
RPS1="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
if (( $+functions[virtualenv_prompt_info] )); then
RPS1+='$(virtualenv_prompt_info)'
fi
RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"
fi
# ...existing code... |
Beta Was this translation helpful? Give feedback.
-
|
The only solution that worked for me was changing the default VSCode terminal to the naked bash. It's quite invoncenient as you need to use this small dropdown next to the "plus" button to add terminal of a choice but it's better than having to copy-paste each terminal output. Just for reference my default terminal is (was?) power10k zsh. The actions are following: |
Beta Was this translation helpful? Give feedback.
-
|
Having this problem on VS2022, anyone knows a fix? |
Beta Was this translation helpful? Give feedback.
-
|
The problem also occurs in the pycharm copilot plugin, the agent starts shells then does not understand commands have completed until the terminal pane is closed. Switching to a simpler / unthemed shell (e.g. It does not seem like there is a way to customise terminal on a per-plugin, but given the plugin is apparently able to name the terminal tab name it seems like it should be able to probe for a working shell setting on its own, or at least probe if it can work with the default terminal settings and request configuration if not. Note that this is not using p10k, you can do the same by hand by customising $PROMPT or $PS1 or whatever. |
Beta Was this translation helpful? Give feedback.
-
|
Bash commands containing non-ASCII bytes (e.g. Cyrillic) hung forever because the harness runs an interactive We fixed it by adding |
Beta Was this translation helpful? Give feedback.
-
|
Now that copilot switched to token pricings that problem is not relevant anymore to me, so this is also a way to fix things ig. |
Beta Was this translation helpful? Give feedback.
-
|
I now have problems with bash too. For example:
That is simple bash. not zsh, no extensions (other than pyenv). |
Beta Was this translation helpful? Give feedback.
-
|
FYI the issue I've been having (inability to see output of long-running commands) seems to have been completely fixed in 1.104.1 I think this is new, I don't recall seeing it before and now the chat will note that integration will improve more with this - https://code.visualstudio.com/docs/terminal/shell-integration That said I am running ksh and didn't have to do this to not experience the same issue. |
Beta Was this translation helpful? Give feedback.
-
|
There are two issues here, one chat doesn't notice the command exited, the other chat returns prematurely and doesn't see the output of long running tasks. For the latter, the issue appears to be that there's a one second timeout buried in the terminal monitor. As soon as there's no output for more than a second it returns. If you run a background loop that prints out a . or newline every .8 seconds while the command is run, it will work. |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
|
here's my updated instructions (added to |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I am also experiencing the same issue, and I have enabled terminal integration too! |
Beta Was this translation helpful? Give feedback.
-
|
I keep running into this issue where copilot will assume the command did not output anything and start debugging I tried adding the following to my custom instructions, to no avail |
Beta Was this translation helpful? Give feedback.
-
|
I have discoevered acouple of workarounds for this; one, via copy-pasting the terminal output and prompting, as in copy the terminal output, pause the execution of copilots current command, and then prompt it with; "your last command gave the output: .. paste terminal output .." copilot then continues as expected, and reads the terminal output properly from the prompt. two: curl seems to cause this issue a lot. I solved it by linking curl to a short wrapper script that executes the curl as given and then echo's a newline, ie: copy your curl binary to something like real_curl, create the following script and link curl to your script; #!/bin/sh |
Beta Was this translation helpful? Give feedback.
-
|
What's been working for me when this starts to happen is to close down all terminals when it asks to run a command. As long as the command runs in a new terminal and there's no pre-existing ones it seems to work. |
Beta Was this translation helpful? Give feedback.
-
|
@MarkWard0110 - I've encountered the exact same issue and have done some investigation that might 🔍 Root Cause AnalysisAfter extensive testing, I believe the issue is related to newline-terminated prompt pattern detection. What the tool expects: This explains why pressing Enter (which creates the newline) immediately allows the agent to continue. ✅ Working Workaround - 100% Success RateI've discovered a reliable workaround that eliminates the need for manual Enter presses: Append # Instead of:
npm install
# Use:
npm install; echo ""This forces a newline after command completion and provides the completion signal the detection mechanism needs. 🧪 Testing ResultsI've tested this workaround across various command types with 100% success:
🔧 Environment ConfirmationYour setup: VSCode from WSL terminal This confirms the issue affects multiple environments, not just WSL. 🚀 Automated SolutionTo make this workaround automatic, I've created GitHub Copilot project instructions:
**CRITICAL: Always append `; echo ""` to PowerShell commands when using `run_in_terminal`**This ensures the workaround is applied automatically in all interactions. 📊 Additional BenefitsBeyond fixing completion detection, this workaround also:
🔧 Suggested Fix for DevelopersIf my analysis is correct, the official fix would involve modifying the prompt detection logic to:
Hope this helps everyone experiencing this frustrating issue! The |
Beta Was this translation helpful? Give feedback.




Thanks for all the details in the comments everyone. I did an investigation into this and the reason it was hard to reproduce is that it only reproduced on old versions of powerlevel10k. For most people, running this will fix the problem and also probably give you new features to play with in p10k:
Going forward we're making these changes to mitigate this issue: