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 andView on GitHub (pinned to 4000b2338a)
Solutions
- Verify the configured working directory (cwd) exists and is readable/writable by the agent process.
- Check agent-side limits (max concurrent sessions, subscription quota) and free up or raise them.
- Confirm the agent is still alive — a crash after initialize surfaces here; check the process-exit stderr log.
- 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
- Ensure work_dir exists and is writable by the agent's user.
- Monitor agent-side session/quota limits and raise them or pool sessions.
- Keep the agent binary healthy (updates, memory headroom) to avoid crashes between initialize and session/new.
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
- acp: initialize: %w
- acp: authenticate (%s): %w
- acp: session/new: empty sessionId
- acp: parse initialize result: %w
- acp: parse session/new: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/1e3d64184e07bc0f.
Report an issue: GitHub.