{"record":{"id":"cc91f993093a7d88","repo":"chenhg5/cc-connect","slug":"session-is-closed-cc91f9","errorCode":null,"errorMessage":"session is closed","messagePattern":"session is closed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/codex/session.go","lineNumber":127,"sourceCode":"\tcs.alive.Store(true)\n\n\tif resumeID != \"\" && resumeID != core.ContinueSession {\n\t\tcs.threadID.Store(resumeID)\n\t}\n\n\treturn cs, nil\n}\n\n// Send launches a codex subprocess.\n// If a threadID exists (from a prior turn or resume), uses `codex exec resume <id> <prompt>`.\n// Otherwise uses `codex exec <prompt>` to start a new conversation.\nfunc (cs *codexSession) Send(prompt string, messageID string, images []core.ImageAttachment, files []core.FileAttachment) error {\n\tif len(files) > 0 {\n\t\tfilePaths := core.SaveFilesToDisk(cs.workDir, messageID, files)\n\t\tprompt = core.AppendFileRefs(prompt, filePaths)\n\t}\n\tif !cs.alive.Load() {\n\t\treturn fmt.Errorf(\"session is closed\")\n\t}\n\n\tprompt, imagePaths, err := cs.stageImages(prompt, images)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tisResume := cs.CurrentSessionID() != \"\"\n\tif !isResume {\n\t\tprompt = prependCodexPromptPreamble(prompt, cs.promptPreamble)\n\t}\n\targs := cs.buildExecArgs(prompt, imagePaths)\n\tif len(cs.cliExtraArgs) > 0 {\n\t\targs = append(append([]string{}, cs.cliExtraArgs...), args...)\n\t}\n\n\tbin := cs.cmd\n\tif bin == \"\" {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/codex/session.go#L109-L145","documentation":"Sentinel guard returned when Send is called on a codexSession whose Stop() has already run, meaning the underlying codex subprocess is gone and the session can no longer accept prompts.","triggerScenarios":"Thrown at agent/codex/session.go:127 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Start a new session via the agent instead of reusing the closed one","Check the session's alive flag before calling Send","Track session lifecycle in the caller so closed sessions are evicted from any active map"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}