Skip to content

fix(cli): Cursor sessionType=worktree crashes ACP on "Using worktree" stdout banner #1085

Description

@heavygee

Summary

Remote spawn of Cursor with sessionType: "worktree" (runner adds --cursor-worktree) crashes ACP within ~5s. Session never gets cursorSessionId, so later reopen fails with 422 missing cursorSessionId.

Environment

  • Host: oos-linux (Linux), HAPI driver soup on :3006
  • Agent: Cursor ACP
  • Confirmed 2026-07-18

Repro

  1. Machine-spawn Cursor with worktree session type, e.g.:
{
  "directory": "/home/heavygee/coding/hapi/driver",
  "agent": "cursor",
  "yolo": true,
  "sessionType": "worktree"
}
  1. Observe session briefly running, then archived / "Session crashed" within ~5s.
  2. Metadata has no cursorSessionId.

Expected

Cursor ACP initializes; worktree banner (if any) does not kill the transport; session stays live and records cursorSessionId.

Actual

  1. Runner passes --cursor-worktree for Cursor worktree sessions (cli/src/runner/run.ts / buildCliArgs).
  2. Cursor Agent ACP prints a human stdout line, e.g. Using worktree: /home/heavygee/.cursor/worktrees/driver/acp.
  3. cli/src/agent/backends/acp/AcpStdioTransport.ts handleLine treats any non-JSON stdout as a fatal protocol error (Failed to parse JSON-RPC from ACP agent), ends stdin, kills the process.
  4. Same transport already ignores non-object JSON (Gemini) but does not ignore plain-text banners.

Log receipts (oos ~/.hapi/logs/)

  • 2026-07-18-14-28-08-pid-60481.log (session 0aedaaf1-dfed-4d6d-bbcc-7cd627940217)
  • 2026-07-18-14-28-35-pid-61084.log (session 098ec462-ef86-4983-b4a0-62f759b0bea0)

Both:

[ACP] Failed to parse JSON-RPC line {"line":"Using worktree: /home/heavygee/.cursor/worktrees/driver/acp",...}
Error: Failed to parse JSON-RPC from ACP agent
  at handleLine (.../AcpStdioTransport.ts:234)

Suggested fix direction

Fail-soft: ignore non-JSON ACP stdout lines (log + continue) and/or specifically isolate Cursor's Using worktree: … banner. Add a regression test that feeds that line through the transport without killing the session. Preserve real protocol errors.

Workaround

Spawn sessionType: "simple" with directory set to an existing git worktree path (skip Cursor nested --worktree). Confirmed live.

Not the same as

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:cursorCursor flavorarea:cliCLI, runner, agent wrappersbugSomething isn't workingstatus:confirmedRepro understood, ready to fix

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions