chenhg5/cc-connect · error

kimiSession: start: %w

Error message

kimiSession: start: %w

What it means

After building the exec.Cmd, kimiSession.Send calls cmd.Start(); any launch failure is wrapped as `kimiSession: start: %w`. The kimi process never starts, no events are emitted, and Send returns this error synchronously. Typical underlying errors are exec.ErrNotFound (binary missing), permission denied (non-executable binary), and chdir errors (missing workDir).

Source

Thrown at agent/kimi/session.go:220

	cmd := exec.CommandContext(ctx, ks.cmd, args...)
	cmd.WaitDelay = 1 * time.Second
	cmd.Dir = ks.workDir
	env := os.Environ()
	if len(ks.extraEnv) > 0 {
		env = core.MergeEnv(env, ks.extraEnv)
	}
	cmd.Env = env

	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return fmt.Errorf("kimiSession: stdout pipe: %w", err)
	}

	var stderrBuf bytes.Buffer
	cmd.Stderr = &stderrBuf

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

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

	return nil
}

func (ks *kimiSession) readLoop(ctx context.Context, cmd *exec.Cmd, stdout io.ReadCloser, stderrBuf *bytes.Buffer, tempFiles []string) {
	defer ks.wg.Done()
	defer func() {
		for _, f := range tempFiles {
			os.Remove(f)
		}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify resolution in the daemon's environment: `sudo -u <daemon-user> which kimi`; if empty, install kimi or configure the absolute binary path in config.toml.
  2. Fix the executable bit: `chmod +x $(which kimi)`.
  3. Ensure the configured workDir exists and is accessible to the daemon user.
  4. For systemd, add Environment=PATH=/usr/local/bin:/usr/bin:/bin (or an absolute command path) to the unit and restart.

Example fix

// config.toml — before
[agents.kimi]
command = "kimi"  # not found under systemd's minimal PATH

// after
[agents.kimi]
command = "/home/user/.local/bin/kimi"
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath(kimiCmd); err != nil {
    return fmt.Errorf("kimi CLI %q not installed or not in PATH for this process", kimiCmd)
}
if info, err := os.Stat(workDir); err != nil || !info.IsDir() {
    return fmt.Errorf("workDir %q does not exist", workDir)
}

Try / catch

if err := sess.Send(prompt, msgID, nil, nil); err != nil {
    if strings.Contains(err.Error(), "kimiSession: start:") {
        return fmt.Errorf("cannot launch kimi CLI (check installation/PATH/workDir): %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Send() on a fresh kimiSession where: (1) the kimi binary is not in the daemon process's PATH (systemd/launchd have minimal PATHs), (2) the binary lacks the executable bit, (3) the configured working directory does not exist or is inaccessible, or (4) an invalid command path is configured.

Common situations: cc-connect running under systemd with PATH=/usr:/bin while kimi is installed via npm/homebrew into a user bin dir; installing kimi after the daemon started; pointing the agent's work_dir at a deleted/renamed project folder; containers without the CLI installed.

Related errors


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