Skip to content

Cursor adapter passes prompt via stdin, causing immediate print-mode exit; stderr is discarded #14

Closed

Description

@j5cfk7qm49-web

Summary

ORCH 1.0.27's Cursor adapter launches Cursor Agent print mode without a positional prompt and then writes the prompt to stdin. Cursor Agent CLI 2026.07.16 rejects that invocation immediately:

Error: No prompt provided for print mode

ORCH then reports only Cursor agent process exited with code 1 because the shared streaming helper never drains or includes stderr.

Environment

  • ORCH: 1.0.27
  • Cursor Agent CLI: 2026.07.16-899851b
  • Node: v24.17.0
  • Platform: Windows (win32)
  • Cursor authentication: logged in
  • orch doctor: Cursor adapter detected successfully

Reproduction

This matches the current CursorAdapter.execute() transport:

"Reply with exactly OK" | cursor-agent -p --output-format stream-json --workspace "$PWD" --yolo

Result:

Error: No prompt provided for print mode
exit 1

The equivalent documented positional-prompt form succeeds:

cursor-agent -p --output-format stream-json --workspace "$PWD" --yolo --trust "Reply with exactly OK"

It emits normal system, user, assistant, and result stream-json events and exits successfully.

In a real project this caused 11/11 Cursor-backed task runs to fail at startup, with zero recorded tokens and empty run event logs.

Cause

The adapter currently builds arguments without the required [prompt...] positional argument:

const args = [
  '-p',
  '--output-format', 'stream-json',
  '--workspace', params.workspace,
  '--yolo',
];

spawn('cursor-agent', args, { stdio: ['pipe', 'pipe', 'pipe'] });
proc.stdin.write(buildFullPrompt(...));

Current Cursor Agent help describes the prompt as a positional argument and does not expose a stdin or --prompt-file option.

Separately, createStreamingEvents() reads only stdout. It does not drain proc.stderr, so the actionable CLI error is discarded and a sufficiently chatty stderr stream can also fill the pipe buffer.

Suggested fix

  1. Append buildFullPrompt(params.systemPrompt, params.prompt) as the final Cursor positional argument.
  2. Add --trust for non-interactive fresh ORCH worktrees.
  3. Use stdio: ['ignore', 'pipe', 'pipe'] for Cursor after moving the prompt.
  4. Drain stderr in createStreamingEvents(), retain a bounded tail, and append it to non-zero-exit/spawn errors.
  5. Add adapter tests covering argument construction and stderr propagation.

A local compiled-bundle hotfix using those changes passed:

  • direct Cursor adapter smoke test;
  • a full 17,983-character assembled ORCH prompt;
  • a real ORCH TUI task that rendered CURSOR_ORCH_TUI_OK and transitioned to done;
  • a Codex control task that rendered CODEX_ORCH_TUI_OK and transitioned to done.

Windows prompt-length caveat

Passing the complete prompt positionally is compatible with the tested 17,983-character prompt, but ORCH should account for Windows' process command-line ceiling for larger team/system prompts. Cursor Agent currently offers no prompt-file option, so a durable bridge/fallback may be required.

Additional verification finding

When the Cursor and Codex smoke tasks were first started simultaneously by the TUI, the Cursor task was marked failed while its run record remained stuck at preparing with no error or events. Retrying the exact same task alone succeeded. This installation also has historical Windows failures saving state.json via atomic temp-file rename (EPERM). That appears to be a separate concurrent state-write/observability race, but it surfaced while verifying this fix and may warrant a follow-up issue.

Activity

  1. github-actions commented on Jul 20, 2026

    @github-actions

    👋 Welcome to ORCH — thanks for opening your first issue!

    We appreciate you taking the time to report this. Here are some helpful links:

    If you'd like to fix this yourself, PRs are very welcome! We have 1493+ tests and strict TypeScript — the CI will guide you.

    ⭐ If you find ORCH useful, consider giving us a star — it helps others discover the project!

  2. oxgeneral commented on Jul 22, 2026

    @oxgeneral
    Owner

    Fixed and released in v1.0.28.

    The fix:

    • passes the assembled prompt as the final positional argument in Cursor print mode;
    • adds --trust for fresh ORCH worktrees;
    • uses ignored stdin instead of piping a prompt Cursor does not read;
    • continuously drains stderr, retains a bounded 4 KB tail, and includes it in spawn and non-zero-exit errors;
    • installs process lifecycle listeners eagerly so immediate failures are not missed;
    • accepts both camelCase and snake_case token usage fields.

    Verification completed before release:

    • full test suite: 2000 passed, 2 skipped;
    • TypeScript check and production build passed;
    • manual full ORCH lifecycle with the official Cursor CLI 2026.07.20-8cc9c0b: todo → in_progress → review → done;
    • exact assistant response and camelCase token usage were persisted;
    • real non-zero error path confirmed that Cursor stderr reaches the adapter error.

    The Windows command-line length caveat and the separate state-write race mentioned in the report are outside this fix and should be tracked independently if they remain reproducible.

    Thank you for the detailed report and reproduction steps.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions