Skip to content

bug(agent-cursor, windows): worker launch fails — POSIX printf + argv-inlined prompt in getLaunchCommand() #2072

@chetwerikoff

Description

@chetwerikoff

Summary

On Windows, worker sessions spawned via @aoagents/ao-plugin-agent-cursor exit within ~1 minute of launch (agent_process_exited, no PR, no acknowledge; lifecycle goes working → detecting → stuck), while the orchestrator session on the same host stays healthy.

Root cause is in how the cursor plugin builds the launch command for the worker path, not in the issue/task content.

getLaunchCommand() (dist/index.js) branches on whether both a systemPromptFile and a separate prompt are present:

  • Worker (both present) emits, roughly:
    agent … -- "$(cat <file>; printf '\n\n'; printf %s '<prompt>')"POSIX sh syntax.
  • Orchestrator (only systemPromptFile) emits:
    agent … -- "$(cat <file>)" → no printf.

On Windows, ao-core platform.js defaults the PTY shell to powershell.exe -Command (no pwsh). In PowerShell, cat (= Get-Content) and $() (subexpression) are valid, so the orchestrator branch survives. But printf does not exist in PowerShell, so the worker branch dies.

Two distinct signatures observed in the PTY:

  • A: printf : The term 'printf' is not recognized + error: unknown option '-ne' — POSIX builtin under PowerShell.
  • B: The command line is too long — the whole prompt is inlined into argv via $(cat <large-file>); for a large body (~24 KB observed) this exceeds the cmd.exe limit (~8191 chars). Independent of shell — switching to bash does not help.

This is independent of "/JSON in the GitHub Issue body: the prompt is read from a file, so its contents are literal and do not break argv.

Environment

  • AO: @aoagents/ao@0.9.x
  • OS: Windows 11 (PowerShell 5.1 as PTY shell; no pwsh)
  • Plugin: @aoagents/ao-plugin-agent-cursor
  • Agent launcher: agent / cursor-agent installed as a Windows .cmd shim

Why AO_SHELL=bash is not a sufficient workaround

platform.js exposes AO_SHELL as a PTY shell override. Setting AO_SHELL=C:\Program Files\Git\bin\bash.exe removes signature A (printf resolves), but then:

  1. agent: command not found — Git Bash does not resolve the Windows agent.cmd launcher; and
  2. after shimming agent, large prompts still hit signature B (command line is too long).

So AO_SHELL=bash does not fix worker launch for non-trivial prompts.

Proposed durable fix

Deliver the worker prompt via a file or an explicit agent flag, instead of inlining it into argv with $(cat …; printf …):

  • avoids POSIX printf on Windows PowerShell (signature A), and
  • avoids the argv length limit for large prompts (signature B).

A cmd.exe-style escape alone (cf. #2003 / #2006 on the code-review path) would not solve signature B, since the prompt would still be inlined into the command line.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions