Skip to content

Claude Code ACP Agent: prompt mode fails with "Query closed before response received" #362

@Lewis-404

Description

@Lewis-404

Description:
The Claude Code ACP agent (@zed-industries/claude-agent-acp) in prompt mode (persistent session) consistently fails shortly after connection with the error "Query closed before response received" and "lastAgentDisconnectReason": "connection_close". The agent disconnects without an exit code or signal, leading to task failures when OpenClaw attempts to use it in a continuous interaction mode.

Context:

  • This occurs when using the OpenClaw Gateway's ACP runtime to spawn a Claude Code agent in a persistent session (analogous to acpx claude prompt).
  • The exec mode (acpx claude exec) works without issues for one-shot tasks.
  • The problem is observed when the ACP runtime relies on the agent's prompt mode for continuous interaction within a session.

Error Message:

"Query closed before response received"
"lastAgentDisconnectReason": "connection_close"

Steps to reproduce (using OpenClaw CLI, assuming acpx plugin is installed and configured):

  1. Configure OpenClaw to use the acpx plugin for ACP runtime.
  2. Attempt to spawn a Claude Code agent in a thread-bound session, e.g., via sessions_spawn(runtime="acp", agentId="claude", mode="session", task="Your task that requires continuous interaction").
  3. Observe the ACP_TURN_FAILED error in the OpenClaw logs, with the underlying cause being the Claude Code agent's connection closing unexpectedly.

Expected behavior:
The Claude Code ACP agent should maintain a persistent connection in prompt mode, allowing for continuous interaction and task execution within an ACP session.

Impact:
This bug prevents the reliable use of Claude Code via OpenClaw's ACP runtime for any tasks requiring multi-turn interaction or persistent sessions.

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