{"record":{"id":"0e0a8b5400a6f99a","repo":"chenhg5/cc-connect","slug":"pi-cannot-determine-session-directory","errorCode":null,"errorMessage":"pi: cannot determine session directory","messagePattern":"pi: cannot determine session directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/pi/pi.go","lineNumber":211,"sourceCode":"\t\tsessions = append(sessions, core.AgentSessionInfo{\n\t\t\tID:           sessionID,\n\t\t\tSummary:      summary,\n\t\t\tMessageCount: msgCount,\n\t\t\tModifiedAt:   info.ModTime(),\n\t\t})\n\t}\n\n\tsort.Slice(sessions, func(i, j int) bool {\n\t\treturn sessions[i].ModifiedAt.After(sessions[j].ModifiedAt)\n\t})\n\n\treturn sessions, nil\n}\n\nfunc (a *Agent) DeleteSession(_ context.Context, sessionID string) error {\n\tsessDir := piSessionDir(a.workDir)\n\tif sessDir == \"\" {\n\t\treturn fmt.Errorf(\"pi: cannot determine session directory\")\n\t}\n\n\tpath := findSessionFile(sessDir, sessionID)\n\tif path == \"\" {\n\t\treturn fmt.Errorf(\"pi: session %q not found\", sessionID)\n\t}\n\treturn os.Remove(path)\n}\n\nfunc (a *Agent) Stop() error { return nil }\n\n// ── ModeSwitcher ─────────────────────────────────────────────\n\nfunc (a *Agent) SetMode(mode string) {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\ta.mode = normalizeMode(mode)\n\tslog.Info(\"pi: mode changed\", \"mode\", a.mode)","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/pi/pi.go#L193-L229","documentation":"A sentinel guard at the top of pi Agent.DeleteSession: piSessionDir returned an empty string, meaning the session storage directory for the current working directory could not be derived. Without it there is nowhere to look for the session file to delete.","triggerScenarios":"Thrown at agent/pi/pi.go:211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the pi storage path conventions are intact for this workDir","Set required environment variables (e.g. HOME) so the path resolves","Verify the pi agent has actually created sessions in this workspace"],"exampleFix":null,"handlingStrategy":"validation","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"}