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
- Machine-spawn Cursor with worktree session type, e.g.:
{
"directory": "/home/heavygee/coding/hapi/driver",
"agent": "cursor",
"yolo": true,
"sessionType": "worktree"
}
- Observe session briefly
running, then archived / "Session crashed" within ~5s.
- Metadata has no
cursorSessionId.
Expected
Cursor ACP initializes; worktree banner (if any) does not kill the transport; session stays live and records cursorSessionId.
Actual
- Runner passes
--cursor-worktree for Cursor worktree sessions (cli/src/runner/run.ts / buildCliArgs).
- Cursor Agent ACP prints a human stdout line, e.g.
Using worktree: /home/heavygee/.cursor/worktrees/driver/acp.
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.
- 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
Summary
Remote spawn of Cursor with
sessionType: "worktree"(runner adds--cursor-worktree) crashes ACP within ~5s. Session never getscursorSessionId, so later reopen fails with 422 missing cursorSessionId.Environment
:3006Repro
{ "directory": "/home/heavygee/coding/hapi/driver", "agent": "cursor", "yolo": true, "sessionType": "worktree" }running, thenarchived/ "Session crashed" within ~5s.cursorSessionId.Expected
Cursor ACP initializes; worktree banner (if any) does not kill the transport; session stays live and records
cursorSessionId.Actual
--cursor-worktreefor Cursor worktree sessions (cli/src/runner/run.ts/buildCliArgs).Using worktree: /home/heavygee/.cursor/worktrees/driver/acp.cli/src/agent/backends/acp/AcpStdioTransport.tshandleLinetreats any non-JSON stdout as a fatal protocol error (Failed to parse JSON-RPC from ACP agent), ends stdin, kills the process.Log receipts (oos
~/.hapi/logs/)2026-07-18-14-28-08-pid-60481.log(session0aedaaf1-dfed-4d6d-bbcc-7cd627940217)2026-07-18-14-28-35-pid-61084.log(session098ec462-ef86-4983-b4a0-62f759b0bea0)Both:
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"withdirectoryset to an existing git worktree path (skip Cursor nested--worktree). Confirmed live.Not the same as
--worktreehang (Claude), different symptom