Skip to content

Preserve inline PowerShell commands in Codex rollouts - #306

Open
Loop (Loop3373) wants to merge 1 commit into
microsoft:mainfrom
Loop3373:codex/powershell-rollout-argv
Open

Loop (Loop3373) wants to merge 1 commit into
microsoft:mainfrom
Loop3373:codex/powershell-rollout-argv

Conversation

@Loop3373

Copy link
Copy Markdown

Summary

Codex CLI on Windows records shell commands as an argv array, for example
[pwsh.exe, -NoProfile, -Command, "python -m pytest -q"]. Rollout conversion
currently joins these arguments with POSIX shell quoting. The resulting
PowerShell invocation hides the inner command from the envfacts classifier,
so it misses repeated command repairs in Windows sessions.

Extract the final script argument for pwsh.exe and powershell.exe when it
follows -Command and the preceding arguments are limited to the standalone
startup switches -NoLogo, -NoProfile, and -NonInteractive. Match the
executable basename and flags case-insensitively and preserve the script
verbatim. Keep the existing conversion for Bash and other input forms,
including a PowerShell -File invocation whose script accepts a parameter
named -Command.

Validation

  • Added offline rollout regressions for an inline PowerShell command and an
    existing /bin/bash -lc command. Both exercise rollout conversion, exit
    status, and the envfacts candidate created when pytest -q fails and
    python -m pytest -q succeeds.
  • Added coverage for PowerShell quotes, multiline scripts, case-insensitive
    matching, -File with and without a script parameter named -Command,
    empty argv, and string input.
  • Fetched upstream main at 1bfeccdcecf48333b22762ad1dd9e36c6dc065df
    on November 22, 2026 (JST). The patch passed
    git apply --check --whitespace=error and applied unchanged in a fresh
    checkout. git diff --check passed after application.
  • On Windows with Python 3.10.8, all 53 tests in tests/test_trace.py and
    tests/test_envfacts.py passed after applying the patch to that checkout.

AI assistance and review scope

OpenAI Codex was used to prepare the patch, regression tests, and this PR
description. The final diff was checked for unrelated changes and local
identifiers. Validation covered patch application to the upstream commit
listed above and the two offline test modules on Windows. The Windows
Codex rollout observed during the investigation informed the test fixtures.
The final regression tests replay synthetic records and do not invoke
Codex CLI or a model. Bash compatibility was tested with a synthetic
/bin/bash -lc record on Windows.

Related pull requests

  • #303 updates
    request counting in trace/codex.py. This patch changes the separate
    command conversion path.
  • #268 handles
    PowerShell tool calls from Claude Code. This patch handles argv recorded
    by Codex CLI.
  • #296 recognizes
    pixi run in Micro-skills command classification. This patch makes the
    inline PowerShell script available to that classification stage.

@Loop3373

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

1 participant