chenhg5/cc-connect · error

antigravitySession: stdout pipe: %w

Error message

antigravitySession: stdout pipe: %w

What it means

Send wraps errors from cmd.StdoutPipe(), which obtains the pipe used to stream the agy process's stdout. This fails only before the process starts — it indicates an OS-level pipe resource error and is practically rare.

Source

Thrown at agent/antigravity/session.go:189

	slog.Debug("antigravitySession: launching", "resume", isResume, "args", core.RedactArgs(args))
	cmd := exec.CommandContext(ctx, as.cmd, args...)
	cmd.WaitDelay = 1 * time.Second
	cmd.Dir = as.workDir
	env := os.Environ()
	if len(as.extraEnv) > 0 {
		env = core.MergeEnv(env, as.extraEnv)
	}
	if as.permissionBridge != nil {
		env = core.MergeEnv(env, as.permissionBridge.Env())
	}
	cmd.Env = env

	// Keep stdin disconnected: agy --print consumes piped stdin to EOF before
	// processing the prompt, so an open pipe would deadlock the turn.
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return fmt.Errorf("antigravitySession: stdout pipe: %w", err)
	}

	var stderrBuf bytes.Buffer
	cmd.Stderr = &stderrBuf

	if err := cmd.Start(); err != nil {
		return fmt.Errorf("antigravitySession: start: %w", err)
	}

	started = true
	as.wg.Add(1)
	go func() {
		defer cancel()
		as.readLoop(ctx, cmd, stdout, &stderrBuf, append(imageRefs, fileRefs...), preEntries, time.Now())
	}()

	return nil
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check the wrapped cause (%w); 'too many open files' means raise ulimit -n or reduce concurrent sessions.
  2. Audit for fd leaks in long-running cc-connect processes (lsof -p <pid> | wc -l).
  3. Restart the daemon if fd usage is leaked.
  4. If persistent under rlimits, lower configured concurrent session counts.

Example fix

// before
$ ulimit -n
256
// after
$ ulimit -n 1024 && cc-connect start
Defensive patterns

Strategy: retry

Try / catch

if err := session.Send(...); err != nil && strings.Contains(err.Error(), "stdout pipe") {
    // wait briefly and retry once; else surface fd-limit remediation
}

Prevention

When it happens

Trigger: cmd.StdoutPipe() returning an error when preparing the agy --print command: fd exhaustion (EMFILE) or an internal os/exec state problem (e.g. Stdout already set, though here it is controlled by the library).

Common situations: System has exhausted file descriptors from many concurrent sessions/processes; running under strict rlimit configurations.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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