{"record":{"id":"6ac246c12d4a50f6","repo":"chenhg5/cc-connect","slug":"session-create-w","errorCode":null,"errorMessage":"session.create: %w","messagePattern":"session\\.create: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/copilot/session.go","lineNumber":201,"sourceCode":"\t\t\tcs.sessionID.Store(resumeSessionID)\n\t\t\tslog.Info(\"copilotSession: session resumed\", \"sessionId\", resumeSessionID)\n\t\tcase <-time.After(10 * time.Second):\n\t\t\treturn fmt.Errorf(\"session.resume timeout\")\n\t\tcase <-cs.ctx.Done():\n\t\t\treturn cs.ctx.Err()\n\t\t}\n\t} else {\n\t\treturn cs.createSession()\n\t}\n\treturn nil\n}\n\nfunc (cs *copilotSession) createSession() error {\n\t_, createCh := cs.rpc.call(\"session.create\", cs.sessionConfig(newCopilotSessionID()))\n\tselect {\n\tcase resp := <-createCh:\n\t\tif resp.Error != nil {\n\t\t\treturn fmt.Errorf(\"session.create: %w\", resp.Error)\n\t\t}\n\t\tvar result struct {\n\t\t\tSessionID string `json:\"sessionId\"`\n\t\t}\n\t\tif err := json.Unmarshal(resp.Result, &result); err != nil {\n\t\t\treturn fmt.Errorf(\"session.create decode: %w\", err)\n\t\t}\n\t\tcs.sessionID.Store(result.SessionID)\n\t\tslog.Info(\"copilotSession: session created\", \"sessionId\", result.SessionID)\n\tcase <-time.After(10 * time.Second):\n\t\treturn fmt.Errorf(\"session.create timeout\")\n\tcase <-cs.ctx.Done():\n\t\treturn cs.ctx.Err()\n\t}\n\treturn nil\n}\n\nfunc (cs *copilotSession) sessionConfig(sessionID string) copilotSessionConfig {","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/copilot/session.go#L183-L219","documentation":"createSession sends the 'session.create' JSON-RPC request to the Copilot CLI process and, if the CLI replies with a JSON-RPC error object, wraps it as 'session.create: %w'. This means the process is alive and responded, but it refused to create the session (bad config, auth, or internal CLI error).","triggerScenarios":"handshake -> createSession -> resp.Error != nil on the 'session.create' call channel; i.e. the Copilot CLI returned an explicit JSON-RPC error for session creation (e.g. invalid sessionConfig, unauthenticated CLI, unsupported model/option in the agent config).","commonSituations":"Copilot CLI not authenticated (expired GitHub token); invalid sessionConfig fields produced from config.toml (bad model name, unsupported option); version mismatch between cc-connect's expectations and the installed CLI's RPC protocol.","solutions":["Read the wrapped cause (%w) in the logs — the underlying resp.Error.Message from the CLI states the real reason.","Re-authenticate the Copilot CLI (run it manually and complete `copilot` login / refresh the GitHub token).","Validate the agent's config.toml options for the copilot agent (model name, flags) against the installed CLI version.","Update or downgrade the Copilot CLI to a version compatible with cc-connect's JSON-RPC protocol.","Retry; if it persists, capture stderr (logged by readLoop) and file an issue with the CLI error text."],"exampleFix":"// before: unclear which option breaks creation\n[[agents]]\nname = \"copilot\"\n[agents.options]\nmodel = \"gpt-5-turbo-ultra\"   # not supported by installed CLI\n// after\n[agents.options]\nmodel = \"gpt-4o\"              # supported by the installed CLI version","handlingStrategy":"try-catch","validationCode":"// verify auth and version before starting the agent\nout, err := exec.Command(\"copilot\", \"auth\", \"status\").Output()\nif err != nil || !strings.Contains(string(out), \"logged in\") {\n    return fmt.Errorf(\"copilot CLI not authenticated\")\n}","typeGuard":null,"tryCatchPattern":"if err := agent.StartSession(ctx, opts); err != nil {\n    var cliErr error\n    if errors.As(err, &cliErr) && strings.Contains(err.Error(), \"session.create:\") {\n        slog.Error(\"CLI rejected session.create\", \"cause\", errors.Unwrap(err))\n    }\n}","preventionTips":["Keep the Copilot CLI authenticated (monitor token expiry)","Match configured model/options to the installed CLI version","Read the wrapped cause (%w) — it is the CLI's own error message","Pin CLI versions in deployment to avoid protocol drift"],"tags":["rpc","json-rpc","session-lifecycle","upstream-error"],"backgroundTag":"api-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}