chenhg5/cc-connect · error
pi: read session dir: %w
Error message
pi: read session dir: %w
What it means
Wraps a failed os.ReadDir of the pi agent's session directory during listing. Not-exist returns no sessions; this error fires only on other IO failures such as permission denial while scanning the pi storage directory.
Source
Thrown at agent/pi/pi.go:173
// 优先生效(getenv 返回第一个匹配项)。
extraEnv = append(extraEnv, core.InjectedAgentEnv(mode)...)
rpc := a.rpc
a.mu.Unlock()
return newPiSession(ctx, a.cmd, extraArgs, a.workDir, model, mode, thinking, rpc, sessionID, extraEnv)
}
func (a *Agent) ListSessions(_ context.Context) ([]core.AgentSessionInfo, error) {
sessDir := piSessionDir(a.workDir)
if sessDir == "" {
return nil, nil
}
entries, err := os.ReadDir(sessDir)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, fmt.Errorf("pi: read session dir: %w", err)
}
var sessions []core.AgentSessionInfo
for _, entry := range entries {
name := entry.Name()
if entry.IsDir() || !strings.HasSuffix(name, ".jsonl") {
continue
}
info, err := entry.Info()
if err != nil {
continue
}
sessionID, summary, msgCount := scanPiSession(filepath.Join(sessDir, name))
if sessionID == "" {
continue
}View on GitHub (pinned to 4000b2338a)
Solutions
- Fix read permissions on the pi sessions directory
- Check for filesystem errors on the path
- Retry /sessions after repair
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at agent/pi/pi.go:173 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/be00973b2f9ba947.
Report an issue: GitHub.