chenhg5/cc-connect · warning

write hook response: %w

Error message

write hook response: %w

What it means

After a valid decision is obtained, Relay re-encodes the BridgeResponse as JSON to the hook's stdout writer (out), which Antigravity reads. This error wraps a failure writing/encoding that final response — the stdout pipe is closed, broken, or the write fails at the OS level.

Source

Thrown at agent/antigravityhook/protocol.go:72

	// fail closed quickly. After connect, wait much longer for a human response.
	_ = conn.SetDeadline(time.Now().Add(bridgeResponseTimeout))

	if err := json.NewEncoder(conn).Encode(BridgeRequest{Token: token, HookInput: input}); err != nil {
		return fmt.Errorf("send permission request: %w", err)
	}

	var response BridgeResponse
	if err := json.NewDecoder(io.LimitReader(conn, 64<<10)).Decode(&response); err != nil {
		return fmt.Errorf("read permission response: %w", err)
	}
	switch response.Decision {
	case "allow", "deny":
	default:
		return fmt.Errorf("invalid permission decision %q", response.Decision)
	}

	if err := json.NewEncoder(out).Encode(response); err != nil {
		return fmt.Errorf("write hook response: %w", err)
	}
	return nil
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Re-run the agent operation — this is usually a lost race where the parent process exited while the decision was pending
  2. Avoid closing/killing the Antigravity process while a permission prompt is outstanding in the messaging app
  3. Check disk space and stdout redirection targets on the machine where the hook runs
  4. If wrapping the hook in a script, keep the original stdout fd open and pass it through unchanged
Defensive patterns

Strategy: try-catch

Try / catch

if err := Relay(in, out, addr, token); err != nil {
    if errors.Is(err, syscall.EPIPE) || strings.Contains(err.Error(), "write hook response") {
        log.Warn("parent process gone before decision could be delivered", "err", err)
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: Relay() calls json.NewEncoder(out).Encode(response) where out is the hook process's stdout; encoding fails if the parent Antigravity process already exited or closed the pipe (EPIPE), stdout is redirected to a full disk, or out is a writer that rejects the write.

Common situations: The IDE/agent that spawned the permission hook was closed by the user while a decision was pending, so the pipe is broken when the human finally answers in chat; a wrapper script closed stdout prematurely; disk-full on the machine running the hook.

Related errors


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