Skip to content

Codex in PowerShell should handle a prefix for a command correctly #8537

Open

Description

@ScottArbeit

What version of Codex is running?

codex-cli 0.77.0

What subscription do you have?

ChatGPT Pro

Which model were you using?

gpt-5.2-codex

What platform is your computer?

Microsoft Windows NT 10.0.26220.0 x64

What issue are you seeing?

I have to approve every form of "dotnet" command in PowerShell; I want to be able to approve all commands that start with "dotnet" in PowerShell, but the rules checking isn't actually a "prefix" check, it's a full-string check.

Here's an example rule (that I manually created) from my default.rules file:

prefix_rule(pattern=["C:\\Program Files\\PowerShell\\7\\pwsh.exe", "-Command", "dotnet build"], decision="allow")

That rule should allow any command that starts with "dotnet build" to be approved, but that's not what Codex is doing.

What steps can reproduce the bug?

Uploaded thread: 019b51e5-05a6-7b60-a2a7-47f3788b68a1

What is the expected behavior?

I want to be able to approve all commands that start with "dotnet" in PowerShell, but the StarLark rules checking isn't actually a "prefix" check, it's a full-string check.

Additional information

The instructions in this issue template for Windows users to gather the version information should be $([Environment]::OSVersion | ForEach-Object VersionString) + ' ' + $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" }). Notice the + ' ' + added between the two $() expressions.

Activity

  1. added
    bug
    on Dec 24, 2025
  2. added
    CLI
    windows-os
    sandbox
    on Dec 24, 2025
  3. removed
    CLI
    on Dec 24, 2025
  4. arthur-st commented on Feb 8, 2026

    @arthur-st

    Can confirm this behavior with Codex v0.98.0 and PowerShell 7.5.4. OS build 26100.7462.

  5. GitMurf commented on Mar 16, 2026

    @GitMurf

    This is killing me! I am using the Windows Sandbox and it needs to escalate privileges for commands for tools like “agent-browser” but as the OP said, I can’t just use prefix with agent-browser or even “agent-browser snapshot” as it must be exact match like “agent-browser snapshot -i”.

    I believe it’s because it is invoking with prefix params like [“powershell_path", "-Command", “the actual cmd to run”] and the way it works doesn’t allow “the actual cmd to run” to match just a prefix as it requires the full command.

    I am thinking maybe something to do with the third param or something because if I just do [“powershell_path", "-Command"] that works as a “prefix” as it let’s everything bypass the sandbox elevated privileges and approves all commands.

    Examples

    Here are some entries that get added to the default.rules when you ask it to "always approve" in the Codex App GUI:

    prefix_rule(pattern=["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command", "agent-browser open http://localhost:3000"], decision="allow")
    prefix_rule(pattern=["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command", "agent-browser click '@e17'"], decision="allow")
    prefix_rule(pattern=["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command", "agent-browser snapshot -i"], decision="allow")
    

    The main problem is things like the agent-browser click commands because they are going to have a specific element reference to click and unless you add every single potential name (e.g., @e17 etc.) then you are going to constantly have to approve the commands.

    My expectation is that the below should work as a "prefix" to allow anything after agent-browser click, but it does not work.

    prefix_rule(pattern=["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command", "agent-browser click"], decision="allow")
    

    And yes I have tried all the different variations like separating each word as an array arg like this:

    prefix_rule(pattern=["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command", "agent-browser", "click"], decision="allow")
    
  6. bratter commented on Mar 20, 2026

    @bratter

    Concur that this is not the ideal behavior!

  7. msg7086 commented on Mar 26, 2026

    @msg7086

    Hope this get resolved soon and I don't have to sit there and keep clicking allow for git add and git commit.

  8. petitchamp commented on Apr 24, 2026

    @petitchamp

    I am also facing this problem. codex keeps asking me for approval. Still no fix ?

  9. Message00 commented on May 1, 2026

    @Message00

    Coming from half a year later.
    It is genuinely hard to believe that this very basic design issue, which has a significant negative impact on the user experience, has seen no progress at all in half a year.
    I have already seen a number of similar issues, and none of them has had any substantive progress — not even a viable workaround.
    It is difficult to understand how such a poor user experience can exist in something being built as the absolute core of OpenAI’s product.

  10. srcejon commented on May 7, 2026

    @srcejon

    @codex can you vibe a fix for us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions