chenhg5/cc-connect · error

acp: write

Error message

acp: write %s: %w

What it means

Raised by transport.call when serializing/writing a JSON-RPC request for the named method to the agent's stdin fails. It fires when the process stdin pipe is broken (agent exited) or the write is rejected; the pending entry is cleaned up and the whole call aborts.

Solutions

  1. Check whether the agent process is still alive before sending (session closed errors usually accompany this)
  2. Restart the session — a broken stdin pipe is not recoverable on the same transport
  3. Look for earlier errors explaining why the agent exited
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at agent/acp/rpc.go:189 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/ac0e1be61e48c385. Report an issue: GitHub.

Appendix: source

Thrown at agent/acp/rpc.go:189

func (t *transport) call(ctx context.Context, method string, params any) (json.RawMessage, error) {
	id := t.nextID.Add(1)
	key := fmt.Sprintf("%d", id)
	ch := make(chan rpcOutcome, 1)
	t.pendingMu.Lock()
	t.pending[key] = ch
	t.pendingMu.Unlock()

	req := map[string]any{
		"jsonrpc": "2.0",
		"id":      id,
		"method":  method,
		"params":  params,
	}
	if err := t.writeJSON(req); err != nil {
		t.pendingMu.Lock()
		delete(t.pending, key)
		t.pendingMu.Unlock()
		return nil, fmt.Errorf("acp: write %s: %w", method, err)
	}
	select {
	case <-ctx.Done():
		t.pendingMu.Lock()
		delete(t.pending, key)
		t.pendingMu.Unlock()
		return nil, ctx.Err()
	case out := <-ch:
		if out.err != nil {
			return nil, out.err
		}
		return out.result, nil
	}
}

func (t *transport) sendNotification(method string, params any) error {
	return t.writeJSON(map[string]any{
		"jsonrpc": "2.0",

View on GitHub (pinned to 4000b2338a)