{"record":{"id":"1e3d64184e07bc0f","repo":"chenhg5/cc-connect","slug":"acp-session-new-w","errorCode":null,"errorMessage":"acp: session/new: %w","messagePattern":"acp: session/new: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/acp/session.go","lineNumber":236,"sourceCode":"\t\t\tvar lr struct {\n\t\t\t\tSessionID string         `json:\"sessionId\"`\n\t\t\t\tModes     *acpModesBlock `json:\"modes\"`\n\t\t\t}\n\t\t\tif json.Unmarshal(loadRes, &lr) == nil && lr.SessionID != \"\" {\n\t\t\t\ts.setACPSessionID(lr.SessionID)\n\t\t\t\ts.absorbModes(lr.Modes)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\n\tnewParams := map[string]any{\n\t\t\"cwd\":        s.workDir,\n\t\t\"mcpServers\": []any{},\n\t}\n\tnewRes, err := s.tr.call(s.ctx, \"session/new\", newParams)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"acp: session/new: %w\", err)\n\t}\n\tvar sn struct {\n\t\tSessionID string         `json:\"sessionId\"`\n\t\tModes     *acpModesBlock `json:\"modes\"`\n\t}\n\tif err := json.Unmarshal(newRes, &sn); err != nil {\n\t\treturn fmt.Errorf(\"acp: parse session/new: %w\", err)\n\t}\n\tif sn.SessionID == \"\" {\n\t\treturn fmt.Errorf(\"acp: session/new: empty sessionId\")\n\t}\n\ts.setACPSessionID(sn.SessionID)\n\ts.absorbModes(sn.Modes)\n\treturn nil\n}\n\n// absorbModes copies a modes block into the session's cache and fans\n// it out to the parent agent callbacks (if any). Both the session and","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/acp/session.go#L218-L254","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: work_dir points to a removed path\nwork_dir = \"/home/me/old-project\"\n// after\nwork_dir = \"/home/me/project\"","handlingStrategy":"retry","validationCode":"if st, err := os.Stat(cfg.WorkDir); err != nil || !st.IsDir() {\n    return fmt.Errorf(\"work_dir %q missing or not a directory\", cfg.WorkDir)\n}","typeGuard":null,"tryCatchPattern":"sess, err := agent.StartSession(ctx, id, nil)\nif err != nil && strings.Contains(err.Error(), \"acp: session/new\") {\n    // transient agent-side limits: bounded retry\n    time.Sleep(2 * time.Second)\n    sess, err = agent.StartSession(ctx, id, nil)\n}\nreturn err","preventionTips":["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."],"tags":["acp","handshake","session","json-rpc"],"backgroundTag":"handshake-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}