Skip to content

[Bug]: [Windows] cursor-agent fails when prompt contains CLI-like flags (e.g. go -ldflags -X) #5649

Description

@WitMiao

Summary

On Windows, when a Cursor agent task prompt contains CLI-like flags (e.g. Go ldflags with -X), cursor-agent exits immediately with:

error: unknown option '-X'
cursor-agent exited with error: exit status 1

The task fails in ~1–2s with failure_reason=agent_error.process_failure and produces no agent output.

This is not the multi-line prompt truncation fixed by #1297 / PR #1709: daemon logs already show the PowerShell -File rewrite path is active (cursor-agent: routing through powershell -File to preserve argv tokens).

Environment

  • OS: Windows 10/11 (amd64)
  • Multica CLI/daemon: 0.4.2 (also reproduced on 0.4.4-era daemon behavior per local logs)
  • cursor-agent: 2026.07.16-899851b
  • Provider: cursor via Cursor runtime
  • Launch path: pwsh.exe -NoProfile -ExecutionPolicy Bypass -File cursor-agent.ps1 -p <prompt> ...

Steps to reproduce

  1. On Windows, run Multica daemon with a Cursor runtime.

  2. Trigger a comment task whose prompt body includes a pasted build log containing:

    go build -ldflags "-X main.version=foo -X main.commit=bar" -o bin/server ./cmd/server

    (In our case this came from a user @mentioning an agent with CI build output in the issue comment.)

  3. Observe the task fail within ~2 seconds.

Expected behavior

The full comment/prompt text should be passed to cursor-agent -p as prompt content. Flags inside the prompt (like -X main.version=...) must not be parsed as cursor-agent CLI options.

Actual behavior

Daemon stderr shows:

[cursor:stderr] error: unknown option '-X'
cursor-agent finished status=failed duration=~2s
agent finished status=failed tools=0 output_bytes=0

buildCursorArgs currently passes:

args := []string{
    "-p", prompt,
    "--output-format", "stream-json",
    "--yolo",
}

Even with Windows chooseCursorInvocation routing through powershell -File, prompt content that looks like CLI flags appears to leak into option parsing.

Related issues (not duplicates)

Suggested fixes

Any of these would likely work:

  1. Pass prompt via stdin / temp file instead of -p <huge string> when it contains ambiguous tokens.
  2. Insert -- after -p (if supported by cursor-agent) before prompt args.
  3. Escape or quote prompt so cursor-agent.ps1 cannot re-tokenize embedded -X flags.
  4. Regression test: Windows fake cursor-agent that asserts prompt argv containing -ldflags "-X main.version=..." arrives as a single -p value.

Minimal repro log excerpt

INF cursor-agent: routing through powershell -File to preserve argv tokens
INF agent command exec=pwsh.exe args=[-NoProfile -ExecutionPolicy Bypass -File .../cursor-agent.ps1 -p ... go build -ldflags "-X main.version=..." ...]
DBG [cursor:stderr] error: unknown option '-X'
INF cursor-agent finished status=failed duration=2.037s

Happy to provide full daemon debug logs on request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions