chenhg5/cc-connect · error
pi: cannot determine session directory
Error message
pi: cannot determine session directory
What it means
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.
Source
Thrown at agent/pi/pi.go:211
sessions = append(sessions, core.AgentSessionInfo{
ID: sessionID,
Summary: summary,
MessageCount: msgCount,
ModifiedAt: info.ModTime(),
})
}
sort.Slice(sessions, func(i, j int) bool {
return sessions[i].ModifiedAt.After(sessions[j].ModifiedAt)
})
return sessions, nil
}
func (a *Agent) DeleteSession(_ context.Context, sessionID string) error {
sessDir := piSessionDir(a.workDir)
if sessDir == "" {
return fmt.Errorf("pi: cannot determine session directory")
}
path := findSessionFile(sessDir, sessionID)
if path == "" {
return fmt.Errorf("pi: session %q not found", sessionID)
}
return os.Remove(path)
}
func (a *Agent) Stop() error { return nil }
// ── ModeSwitcher ─────────────────────────────────────────────
func (a *Agent) SetMode(mode string) {
a.mu.Lock()
defer a.mu.Unlock()
a.mode = normalizeMode(mode)
slog.Info("pi: mode changed", "mode", a.mode)View on GitHub (pinned to 4000b2338a)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at agent/pi/pi.go:211 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/0e0a8b5400a6f99a.
Report an issue: GitHub.