# Agent/Model Tries Using PowerShell Commands when Cmd is the Default Terminal

**URL:** <https://forum.cursor.com/t/agent-model-tries-using-powershell-commands-when-cmd-is-the-default-terminal/154914>\
**Category:** Bug Reports\
**Tags:** terminal, windows\
**Created:** [March 16, 2026, 4:36pm UTC](https://forum.cursor.com/t/agent-model-tries-using-powershell-commands-when-cmd-is-the-default-terminal/154914 "2026-03-16T16:36:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leland\_Hepworth](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Leland\_Hepworth](https://forum.cursor.com/u/Leland_Hepworth)\
**Post date:** [March 16, 2026, 4:36pm UTC](https://forum.cursor.com/t/agent-model-tries-using-powershell-commands-when-cmd-is-the-default-terminal/154914/1 "2026-03-16T16:36:56Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

When Cmd is the default terminal, the Agent isn’t properly detecting that and reporting it to the model, so the model tries using PowerShell specific commands and syntax, which result in errors in Cmd.

This was confirmed as a known bug in the following reply, but I’m creating a separate post for visibility to other users and so we can track progress on getting it resolved:

> [@Post-execution delay where agent remains in “running command” state after output is already returned](https://forum.cursor.com/t/post-execution-delay-where-agent-remains-in-running-command-state-after-output-is-already-returned/151780/13):
>
> @Leland_Hepworth, glad the sleep issue is gone. About the agent using PowerShell commands when cmd is the default terminal, that’s a known bug. The agent doesn’t always correctly detect which shell is active, so it may send PowerShell commands. As a temporary workaround, you can add something like this to your project-level .cursor/rules: When running terminal commands, always use cmd.exe syntax, not PowerShell. The default shell is Command Prompt. This won’t guarantee a 100% fix, but it sho…

> [@Post-execution delay where agent remains in “running command” state after output is already returned](https://forum.cursor.com/t/post-execution-delay-where-agent-remains-in-running-command-state-after-output-is-already-returned/151780/13):
>
> About the agent using PowerShell commands when cmd is the default terminal, that’s a known bug. The agent doesn’t always correctly detect which shell is active, so it may send PowerShell commands.
> 
> As a temporary workaround, you can add something like this to your project-level `.cursor/rules`:
> 
> ```auto
> When running terminal commands, always use cmd.exe syntax, not PowerShell. The default shell is Command Prompt.
> 
> ```
> 
> This won’t guarantee a 100% fix, but it should reduce the number of wrong PowerShell calls.

Similar behavior is also mentioned in the following old posts, but no resolution was provided:

> [@Agent terminal confusion](https://forum.cursor.com/t/agent-terminal-confusion/54918):
>
> An issue I am running into a lot is terminal confusion - the agent doesn’t realise which terminal it is currently running in. For example, when using powershell it often uses && rather than ; for chaining commands. Other times they open another shell, like an SSL connection or an R terminal, and they lose track of what OS/terminal they are working in. I have tried to remind the AI using user rules, but I guess this something that could be partly addressed in the back-end prompt etc…

> [@The Agent tries to use PowerShell!](https://forum.cursor.com/t/the-agent-tries-to-use-powershell/78958):
>
> lady_beetle Provide a clear description of the bug Strangely, on my Ubuntu, the agent tries to send command using Powershell. Powershell is indeed installed but it is not the default terminal “language”, it is sh. When I do ask to commit/push, it generate errors like this git add . && git commit -m “feat: implement …” “System.InvalidOperationException: Cannot locate the offset in the rendered text that was pointed by the origina l cursor. Initial Coord: (64, 14) Buffer: (111, 16) Cursor: …

### Steps to Reproduce

The bug is intermittent, but you set your default terminal to Cmd and start an agent prompt that will trigger calls to the terminal tool. The model may try to use PowerShell commands and syntax, resulting in an error.

### Expected Behavior

The agent correctly reports which terminal is active (i.e. Cmd), and the model never tries to run commands that will only work in a different terminal (i.e. PowerShell).

### Operating System

Windows 10/11

### Version Information

Version: 2.6.18 (system setup)  
VSCode Version: 1.105.1  
Commit: 68fbec5aed9da587d1c6a64172792f505bafa250  
Date: 2026-03-10T02:01:17.430Z  
Build Type: Stable  
Release Track: Default  
Electron: 39.6.0  
Chromium: 142.0.7444.265  
Node.js: 22.22.0  
V8: 14.2.231.22-electron.0  
OS: Windows\_NT x64 10.0.26100

### For AI issues: which model did you use?

Sonnet and Opus, but likely other models as well.

### For AI issues: add Request ID with privacy disabled

I can’t disable privacy on my company managed team account.

### Additional Information

This bug not only increases the processing time of the prompt, the erroneous terminal tool call also results in more cache read token sage, which increases the cost of the prompt. See also:

> [@Why does Cursor consume an absurd amount of cache read tokens?](https://forum.cursor.com/t/why-does-cursor-consume-an-absurd-amount-of-cache-read-tokens/151439):
>
> Looking only at the model output pricing is misleading. I believe Cursor actually makes money on cache reads. Even for a very small change in a single file, with the right context and explanation in the prompt, I’m seeing 178,304 cache read tokens. That’s insane. Why does this happen? For every new model available in Cursor, the first thing I look at in the pricing is the cache read cost, not the output.

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [March 16, 2026, 5:19pm UTC](https://forum.cursor.com/t/agent-model-tries-using-powershell-commands-when-cmd-is-the-default-terminal/154914/4 "2026-03-16T17:19:41Z")

</div>

Hey, thanks for making a separate post so it’s easier to see. This is a known bug. On Windows, the agent’s shell detection defaults to PowerShell no matter what terminal profile you’ve set.

Your `.cursor/rules` workaround is the best option right now:

```plaintext
When running terminal commands, always use cmd.exe syntax, not PowerShell. The default shell is Command Prompt.

```

The team knows about the issue. There’s no ETA for a fix yet, but your report and the others you linked help us prioritize it.

Let me know if the rules workaround still isn’t enough.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [April 7, 2026, 5:21pm UTC](https://forum.cursor.com/t/agent-model-tries-using-powershell-commands-when-cmd-is-the-default-terminal/154914/6 "2026-04-07T17:21:17Z")

</div>

Closed on April 7, 2026, 5:21pm UTC

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.
