Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Agent is suggests && in non-supporting versions of pwsh, awk in pwsh on Windows, etc. #6073

Closed

Description

I asked the agent to generate a README, then asked to commit.
The agent then tried to execute git add README.md && git commit -m "Add README file" in its own powershell terminal, which errors into

PS E:\Dropbox\code\pypeduct> git add README.md && git commit -m "Add README file"
In Zeile:1 Zeichen:19

  • git add README.md && git commit -m "Add README file"
  •               ~~
    

Das Token "&&" ist in dieser Version kein gÞltiges Anweisungstrennzeichen.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine

Copilot Chat Extension Version: 0.25.2025030404
Version: 1.98.0-insider (user setup)
Commit: 21d13f4350b0651abfae76b98651d7c72551dff1
Date: 2025-03-04T06:32:40.978Z
Electron: 34.2.0
ElectronBuildId: 11044223
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Windows_NT x64 10.0.19045

Image

Activity

  1. Tyriar commented on Mar 6, 2025

    @Tyriar

    && actually is supported by more recent versions of pwsh, so that could workaround this issue by updating.

  2. amogorkon commented on Mar 6, 2025

    @amogorkon
    Author

    Ok, I upgraded Powershell, which fixes this issue. It might be nice to catch this error and point the user in the right direction.

  3. Tyriar commented on Mar 6, 2025

    @Tyriar

    Anselm Kiefner (@amogorkon) yeah I'm going to see if we can give a hint about the pwsh version to help here. Changing the model being used might improve how it's handling the error, it's a little surprising it's just being ignored.

  4. 16 remaining items

  5. hediet commented on Jul 3, 2025

    @hediet
    Member

    Still happens:
    Image

    But the log doesn't mention && anymore. Would be interesting to collect telemetry about how many tokes this burns. Maybe we can do something smarter (e.g. auto fixing && to ;)

  6. Frulfump commented on Jul 3, 2025

    @Frulfump

    But the log doesn't mention && anymore. Would be interesting to collect telemetry about how many tokes this burns. Maybe we can do something smarter (e.g. auto fixing && to ;)

    Doesn't it make more sense to make it understand in which environment it's operating within, i.e if it knows it's using the legacy PowerShell (powershell.exe) would it still suggest using && which is perfectly fine to use in modern PowerShell (pwsh.exe)? I seem to have made Copilot use modern PowerShell so I don't run into this issue, not exactly sure how but I think I might have changed the default terminal profile.

  7. Tyriar commented on Jul 3, 2025

    @Tyriar

    Frulfump that's exactly what we do. LLMs are non-deterministic and don't like to listen sometimes. This is included only when the binary is powershell.exe:

    Image
  8. Tyriar commented on Jul 3, 2025

    @Tyriar

    Henning Dieterichs (@hediet) I tried to reproduce this on sonnet 4 and got it to happen 1 out of 10 tries and then I gave up. I verified && isn't mentioned and the hint to use ; is included. I'm going to make this out of scope for now as it's rare and the situation should improve over time as models do and it self heals by just running another one.

    When/if we add actual parsing of the shell command via tree-sitter or something this is something we could do reliably, otherwise we risk bricking the command.

  9. hediet commented on Jul 3, 2025

    @hediet
    Member

    Would still be valuable to have telemetry to get insights of how many times this (and other situations) happen!
    Maybe whenever a terminal command fails, with a 10% chance we can ask LLM to summarize the error into 1-5 words and send that via telemetry.

  10. Tyriar commented on Jul 3, 2025

    @Tyriar

    Henning Dieterichs (@hediet) we have telemetry around the number of commands that fail. Getting the LLM to summarize an arbitrary string like that would be classified as PII

  11. amogorkon commented on Jul 3, 2025

    @amogorkon
    Author

    Maybe tackle it from the other side: don't just try to prevent the issue but rather catch the exception and print Suggestions how to recover: {self.recovery_actions}" (with recovery_actions being a json list of different possible solutions) so the agent can try to resolve the issue ideally without user intervention.

  12. Tyriar commented on Jul 3, 2025

    @Tyriar

    Anselm Kiefner (@amogorkon) it already does that which is why I think it's not such a big deal, especially since it rarely happens (at least for me):

    Image

    Before I wouldn't be surprised if it wouldn't be able to figure it out, but the failure is enough at least in the screenshot above to nudge it to listen to the instructions about Windows PowerShell.

  13. amogorkon commented on Jul 3, 2025

    @amogorkon
    Author

    Hmm. I'm tinkering with such "enriched" exceptions for my own projects and oftentimes it works as intented, but sometimes it seems the agent just ignores everything. Any idea what could be the reason and how to make it listen more aggressively? For instance, I found that it works best if the recovery suggestions are last in the output and are largely ignored if printed before the traceback. Does the agent combine temporaly correlated output of stdout and stderr?

  14. Tyriar commented on Jul 3, 2025

    @Tyriar

    Anselm Kiefner (@amogorkon) based on my experience when there's a lot of context sometimes it just gets ignored, to what extent also depends on the model being used. Re-writing the command as Henning Dieterichs (@hediet) suggested is probably the right solution in the end, but since this is such a minor issue after the main problem was fixed it doesn't justify the investment for now.

    For instance, I found that it works best if the recovery suggestions are last in the output and are largely ignored if printed before the traceback.

    There is a recency bias, but it is relatively close to the bottom in a user message.

    Does the agent combine temporaly correlated output of stdout and stderr?

    It's all a single stream in the terminal, not like regular process launching. Any time I've seen it recently it rewrites it on next attempt fine.

  15. hediet commented on Jul 7, 2025

    @hediet
    Member

    Another issue is that it often outputs bash commands in a powershell environment, which then often fails (especially for more complicated commands). I guess this is basically the same error - the LLM ignores the terminal environment.

  16. Frulfump commented on Jul 7, 2025

    @Frulfump

    Another issue is that it often outputs bash commands in a powershell environment, which then often fails (especially for more complicated commands). I guess this is basically the same error - the LLM ignores the terminal environment.

    Yeah I've run into this as well and I think as you mention that it's the same kind of category of issues.

    I've tried to mitigate it with rules like

    The tools grep, tail, wc, head, cat, sed and touch is not available on Windows by default so don't try to use it unless explicitly asked to

    In PowerShell you can't use the alias rm with the argument rm -rf because the parameter does not exist on the Remove-Item command which the alias point towards

    The ls alias in PowerShell doesn't support the -la parameter

    But as the models aren't always following rules it fails sometimes but at least it happens less with the rules above.

  17. Tyriar commented on Jul 7, 2025

    @Tyriar

    Moved the running of commands that it generally shouldn't be doing in pwsh to this issue: microsoft/vscode#254431

  18. locked and limited conversation to collaborators on Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugchat-agent-terminalimportantIssue identified as high-priorityverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions