chenhg5/cc-connect · error

acp: session/new: %w

Error message

acp: session/new: %w

What it means

Wrapped when the JSON-RPC `session/new` request fails during handshake (after a successful initialize/authenticate). Without a new ACP session id the cc-connect session cannot start, so newACPSession returns this error and closes the agent process.

Source

Thrown at agent/acp/session.go:236

			var lr struct {
				SessionID string         `json:"sessionId"`
				Modes     *acpModesBlock `json:"modes"`
			}
			if json.Unmarshal(loadRes, &lr) == nil && lr.SessionID != "" {
				s.setACPSessionID(lr.SessionID)
				s.absorbModes(lr.Modes)
				return nil
			}
		}
	}

	newParams := map[string]any{
		"cwd":        s.workDir,
		"mcpServers": []any{},
	}
	newRes, err := s.tr.call(s.ctx, "session/new", newParams)
	if err != nil {
		return fmt.Errorf("acp: session/new: %w", err)
	}
	var sn struct {
		SessionID string         `json:"sessionId"`
		Modes     *acpModesBlock `json:"modes"`
	}
	if err := json.Unmarshal(newRes, &sn); err != nil {
		return fmt.Errorf("acp: parse session/new: %w", err)
	}
	if sn.SessionID == "" {
		return fmt.Errorf("acp: session/new: empty sessionId")
	}
	s.setACPSessionID(sn.SessionID)
	s.absorbModes(sn.Modes)
	return nil
}

// absorbModes copies a modes block into the session's cache and fans
// it out to the parent agent callbacks (if any). Both the session and

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify the configured working directory (cwd) exists and is readable/writable by the agent process.
  2. Check agent-side limits (max concurrent sessions, subscription quota) and free up or raise them.
  3. Confirm the agent is still alive — a crash after initialize surfaces here; check the process-exit stderr log.
  4. Retry after transient agent load; if persistent, update or reinstall the agent binary.

Example fix

// before: work_dir points to a removed path
work_dir = "/home/me/old-project"
// after
work_dir = "/home/me/project"
Defensive patterns

Strategy: retry

Validate before calling

if st, err := os.Stat(cfg.WorkDir); err != nil || !st.IsDir() {
    return fmt.Errorf("work_dir %q missing or not a directory", cfg.WorkDir)
}

Try / catch

sess, err := agent.StartSession(ctx, id, nil)
if err != nil && strings.Contains(err.Error(), "acp: session/new") {
    // transient agent-side limits: bounded retry
    time.Sleep(2 * time.Second)
    sess, err = agent.StartSession(ctx, id, nil)
}
return err

Prevention

When it happens

Trigger: The agent returned a JSON-RPC error for `session/new` (refused to create a session, out of quota, invalid cwd) or the transport call failed/timed out; also reached after a failed session/load falls back to session/new.

Common situations: Agent hit its concurrency/session limit; configured work_dir does not exist or is inaccessible to the agent; agent license/auth allows initialize but not session creation; agent crashed between initialize and session/new.

Related errors


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