Skip to content

fix #475: guide Windows shell execution and report quoting hazards - #476

Closed
ahmad-ajmal wants to merge 1 commit into
devfrom
codex/fix-windows-shell-guidance
Closed

ahmad-ajmal wants to merge 1 commit into
devfrom
codex/fix-windows-shell-guidance

Conversation

@ahmad-ajmal

Copy link
Copy Markdown
Collaborator

What

Windows shell commands can fail or silently produce incorrect output when an agent wraps PowerShell source in another interpreter. Teach the agent to select PowerShell explicitly and pass raw source. Add the selected shell, resolved interpreter and advisory recovery guidance to Windows run_shell results, including successful nested calls that may have changed semantics.

Closes #475.

Why

A nested $n=2; Write-Output $n loses its variables before the inner PowerShell executes. A single-quoted -Command wrapper can return exit code 0 while printing the script as a string. The new tool and system-prompt guidance explains these traps and gives the direct disk-query payload. Explicit cmd, default/auto routing and intentional nested execution retain their behavior; submitted commands are never rewritten or retried automatically.

How to test

  • python -m unittest discover -s tests/windows_shell -v — 17 tests pass locally on Windows, including seven direct-script cases each on Windows PowerShell and pwsh, the disk query, both silent-output reproductions, parser guidance, cmd compatibility, nonzero exits, timeout registration/cleanup and background completion.
  • ruff format --check . and ruff check . with Ruff 0.16.1 — repository-wide checks pass (1655 formatted files).
  • python -m compileall -q app agent_core agents decorators skills — passes.
  • git diff --check — passes.

Add a focused Windows CI workflow that runs these tests using only the Python standard library. The tests execute the production function source with real OS processes, while stubbing only Node PATH preparation and cancellation registration. Full user-triggered cancellation and an end-to-end LLM retry-count comparison are not covered.

Scope

Recovery guidance recognizes common nested powershell/pwsh -Command wrappers and known parser-error markers. It is advisory and does not establish whether arbitrary successful output is correct. The existing direct -Command transport passed the reproductions, so this change does not introduce EncodedCommand or temporary scripts.

Signed-off-by: ahmad-ajmal <ahmadajmal1514@gmail.com>
@ahmad-ajmal ahmad-ajmal closed this Oct 7, 2026
@ahmad-ajmal
ahmad-ajmal deleted the codex/fix-windows-shell-guidance branch October 7, 2026 11:07
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