[GH-ISSUE #84] fix: Cursor agent fails with ACP protocol mismatch (NDJSON vs Content-Length framing) #38

Closed
opened 2026-10-18 14:02:16 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @steamEngineer on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/84

Problem

The Cursor CLI agent (agent acp) uses newline-delimited JSON (NDJSON) for stdin/stdout communication, but the ACP client in cptr only supported Content-Length framed JSON-RPC (Content-Length: N\r\n\r\n{json}). This caused a bidirectional protocol mismatch:

  • Cursor sends NDJSON responses that the cptr reader could not parse
  • cptr sent Content-Length framed requests that Cursor could not parse

Result: the Cursor agent could appear connected but fail with auth/protocol errors, and models were not discoverable in the UI.

Root cause

cptr/utils/agents/acp.py hardcoded Content-Length framing in _send() and expected Content-Length framing in _reader_loop(). Both Cursor (agent acp) and Grok (agent stdio) actually speak NDJSON with current CLIs.

Proposed fix

  • Update _send() to write NDJSON ({json}\n) instead of Content-Length framing
  • Update _reader_loop() to parse NDJSON as the primary protocol
  • Keep Content-Length parsing as a read-side fallback via _extract_json_message() for other ACP implementations

Verification

Tested locally on this machine:

Agent Command Content-Length request NDJSON request
Cursor agent acp No response Works
Grok CLI 0.2.67 grok agent stdio Rejected with parse error Works

The previous Content-Length-only _send() was incompatible with both agents.

Contribution status

I have a fix ready on my fork (steamEngineer/computer, branch fix/cursor-agent-ndjson-support), but PR creation appears restricted on this repository for outside contributors. If maintainers can enable PRs from forks or accept the patch another way, I am happy to submit.

Files affected

  • cptr/utils/agents/acp.py (~18 insertions, 8 deletions)
Originally created by @steamEngineer on GitHub (Jun 28, 2026). Original GitHub issue: https://github.com/open-webui/computer/issues/84 ## Problem The Cursor CLI agent (`agent acp`) uses newline-delimited JSON (NDJSON) for stdin/stdout communication, but the ACP client in cptr only supported Content-Length framed JSON-RPC (`Content-Length: N\r\n\r\n{json}`). This caused a bidirectional protocol mismatch: - Cursor sends NDJSON responses that the cptr reader could not parse - cptr sent Content-Length framed requests that Cursor could not parse Result: the Cursor agent could appear connected but fail with auth/protocol errors, and models were not discoverable in the UI. ## Root cause `cptr/utils/agents/acp.py` hardcoded Content-Length framing in `_send()` and expected Content-Length framing in `_reader_loop()`. Both Cursor (`agent acp`) and Grok (`agent stdio`) actually speak NDJSON with current CLIs. ## Proposed fix - Update `_send()` to write NDJSON (`{json}\n`) instead of Content-Length framing - Update `_reader_loop()` to parse NDJSON as the primary protocol - Keep Content-Length parsing as a read-side fallback via `_extract_json_message()` for other ACP implementations ## Verification Tested locally on this machine: | Agent | Command | Content-Length request | NDJSON request | |-------|---------|------------------------|----------------| | Cursor | `agent acp` | No response | Works | | Grok CLI 0.2.67 | `grok agent stdio` | Rejected with parse error | Works | The previous Content-Length-only `_send()` was incompatible with both agents. ## Contribution status I have a fix ready on my fork (`steamEngineer/computer`, branch `fix/cursor-agent-ndjson-support`), but **PR creation appears restricted** on this repository for outside contributors. If maintainers can enable PRs from forks or accept the patch another way, I am happy to submit. ## Files affected - `cptr/utils/agents/acp.py` (~18 insertions, 8 deletions)
Author
Owner

@steamEngineer commented on GitHub (Jun 28, 2026):

PR submission blocked

I attempted to open a PR from steamEngineer/computer:fix/cursor-agent-ndjson-support → open-webui/computer:main, but GitHub returned:

steamEngineer does not have the correct permissions to execute CreatePullRequest

The fix is ready on the fork:

If maintainers can grant fork PR permissions or cherry-pick from the branch above, the patch is a single commit touching cptr/utils/agents/acp.py (18 insertions, 8 deletions).

Proposed PR title

fix(acp): add newline-delimited JSON support for Cursor agent

Proposed PR body (for when PRs are enabled)

What does this fix/solve?

  • Cursor agent connects, authenticates, and lists models in the cptr UI
  • Outbound requests use NDJSON framing (verified for both Cursor agent acp and Grok CLI 0.2.67 agent stdio)
  • Read-side Content-Length fallback preserved for other ACP implementations

Verification

Agent Command Content-Length request NDJSON request
Cursor agent acp No response Works
Grok CLI 0.2.67 grok agent stdio Rejected Works

The previous Content-Length-only _send() was incompatible with both agents.

<!-- gh-comment-id:4823819765 --> @steamEngineer commented on GitHub (Jun 28, 2026): ## PR submission blocked I attempted to open a PR from `steamEngineer/computer:fix/cursor-agent-ndjson-support` → `open-webui/computer:main`, but GitHub returned: > `steamEngineer does not have the correct permissions to execute CreatePullRequest` The fix is ready on the fork: - **Fork:** https://github.com/steamEngineer/computer - **Branch:** `fix/cursor-agent-ndjson-support` - **Compare:** https://github.com/open-webui/computer/compare/main...steamEngineer:computer:fix/cursor-agent-ndjson-support If maintainers can grant fork PR permissions or cherry-pick from the branch above, the patch is a single commit touching `cptr/utils/agents/acp.py` (18 insertions, 8 deletions). ### Proposed PR title `fix(acp): add newline-delimited JSON support for Cursor agent` ### Proposed PR body (for when PRs are enabled) **What does this fix/solve?** - Cursor agent connects, authenticates, and lists models in the cptr UI - Outbound requests use NDJSON framing (verified for both Cursor `agent acp` and Grok CLI 0.2.67 `agent stdio`) - Read-side Content-Length fallback preserved for other ACP implementations **Verification** | Agent | Command | Content-Length request | NDJSON request | |-------|---------|------------------------|----------------| | Cursor | `agent acp` | No response | Works | | Grok CLI 0.2.67 | `grok agent stdio` | Rejected | Works | The previous Content-Length-only `_send()` was incompatible with both agents.
Author
Owner

@tjbck commented on GitHub (Jun 30, 2026):

Should be addressed!

<!-- gh-comment-id:4839253712 --> @tjbck commented on GitHub (Jun 30, 2026): Should be addressed!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/computer#38
No description provided.