chenhg5/cc-connect · error
iflowSession: start pty: %w
Error message
iflowSession: start pty: %w
What it means
Wraps a failed pty.Start in iflowSession.Send: the interactive iflow turn must run under a pseudo-terminal, and the OS refused to allocate one or exec the process. The turnActive flag is reset so the session is not stuck; causes include missing /dev/ptmx, fd limits, or a dead binary.
Source
Thrown at agent/iflow/session.go:201
} else if s.sentOnce.Load() {
args = append(args, "-c")
}
args = append(args, "-i", prompt)
slog.Debug("iflowSession: launching interactive turn", "resume", sid != "", "args", core.RedactArgs(args))
cmd := exec.CommandContext(turnCtx, s.cmd, args...)
cmd.Dir = s.workDir
env := os.Environ()
if len(s.extraEnv) > 0 {
env = core.MergeEnv(env, s.extraEnv)
}
cmd.Env = env
ptmx, err := pty.Start(cmd)
if err != nil {
s.turnActive.Store(false)
return fmt.Errorf("iflowSession: start pty: %w", err)
}
s.sentOnce.Store(true)
s.wg.Add(1)
go s.readLoop(turn, cmd, ptmx)
return nil
}
func (s *iflowSession) readLoop(turn *iflowTurn, cmd *exec.Cmd, ptmx *os.File) {
defer s.wg.Done()
defer s.turnActive.Store(false)
defer turn.cancel()
defer ptmx.Close()
var termBuf bytes.Buffer
drainDone := make(chan struct{})
go func() {
_, _ = io.Copy(&termBuf, ptmx)View on GitHub (pinned to 4000b2338a)
Solutions
- Verify the iflow CLI is still present and executable: `which iflow && iflow --version`
- Check file-descriptor/process limits (ulimit -n) if PTY allocation fails
- Ensure the container/runtime exposes /dev/pts (run with a tty-capable setup)
- Recreate the agent/session so exec.LookPath re-resolves the binary
Example fix
// before
cmd := exec.Command("iflow", args...) // stale binary path
// after
bin, err := exec.LookPath("iflow")
if err != nil { return fmt.Errorf("iflow CLI missing: %w", err) }
cmd := exec.Command(bin, args...) Defensive patterns
Strategy: try-catch
Validate before calling
bin, err := exec.LookPath("iflow")
if err != nil || unix.Access(bin, unix.X_OK) != nil {
return fmt.Errorf("iflow binary missing or not executable")
} Try / catch
if err := session.Send(ctx, msg, nil); err != nil {
if strings.Contains(err.Error(), "start pty") {
log.Printf("pty start failed, check fd limits and /dev/pts: %v", err)
return recreateSessionAndRetry()
}
} Prevention
- Run health checks (DoctorChecker) that verify the CLI is executable before sending
- Raise RLIMIT_NOFILE in containers running many sessions
- Ensure the runtime provides /dev/pts for PTY allocation
When it happens
Trigger: Calling Send() when pty.Start fails — the iflow binary vanished from PATH after New(), the resolved command path is not executable, argument list is invalid, or PTY allocation failed (resource limits, non-tty-capable environment).
Common situations: CLI uninstalled/upgraded between agent construction and session use; sandbox/container without /dev/ptmx; too many open files; binary lacks execute permission after a partial update.
Related errors
- antigravitySession: stdout pipe: %w
- antigravitySession: start: %w
- codex app-server stdin pipe: %w
- codex app-server stdout pipe: %w
- codex app-server stderr pipe: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/bb3550be0f480154.
Report an issue: GitHub.