charmbracelet/crush · error
failed to resolve session: %w
Error message
failed to resolve session: %w
What it means
Wraps errors from resolveSession(), which finds the session for a non-interactive run based on --continue (session id) or --last flags. Thrown when no matching session exists or session lookup fails.
Source
Thrown at internal/cmd/run.go:237
}
}
// Wait for the agent to become ready (MCP init, etc).
if err := waitForAgent(ctx, c, ws.ID); err != nil {
stopSpinner()
return fmt.Errorf("agent not ready: %w", err)
}
// Force-update agent models so MCP tools are loaded.
if err := c.UpdateAgent(ctx, ws.ID); err != nil {
slog.Warn("Failed to update agent", "error", err)
}
defer stopSpinner()
sess, err := resolveSession(ctx, c, ws.ID, continueSessionID, useLast)
if err != nil {
return fmt.Errorf("failed to resolve session: %w", err)
}
if continueSessionID != "" || useLast {
slog.Info("Continuing session for non-interactive run", "session_id", sess.ID)
// If no explicit model override was requested, restore the
// model/provider from the last assistant message in the
// session, provided it is still available.
if largeModel == "" && smallModel == "" {
if err := restoreModelFromSession(ctx, c, ws, sess.ID); err != nil {
slog.Warn("Failed to restore model from session", "error", err)
}
}
} else {
slog.Info("Created session for non-interactive run", "session_id", sess.ID)
}
events, err := c.SubscribeEvents(ctx, ws.ID)
if err != nil {
return fmt.Errorf("failed to subscribe to events: %w", err)View on GitHub (pinned to 7944b8e522)
Solutions
- List existing sessions (`crush sessions`) and copy the exact id
- Omit --continue/--last to create a new session instead
- Run from the same project directory used when the session was created
- Check the local SQLite database exists and is readable
Example fix
// before crush run --continue abc123 "continue" // after: use the exact session id crush run --continue 0195f2a1-7c3b-7e22-9d4e-1a2b3c4d5e6f "continue"
Defensive patterns
Strategy: fallback
Validate before calling
// verify the session exists before asking for --continue
if continueSessionID != "" {
if _, err := q.GetSession(ctx, continueSessionID); err != nil {
return fmt.Errorf("session %q not found; omit --continue to start fresh", continueSessionID)
}
} Try / catch
sess, err := resolveSession(ctx, c, ws.ID, continueSessionID, useLast)
if err != nil {
if useLast || continueSessionID != "" {
slog.Warn("Session not found, starting a new one")
sess, err = createNewSession(ctx, c, ws.ID)
}
if err != nil {
return fmt.Errorf("failed to resolve session: %w", err)
}
} Prevention
- Copy session ids from `crush sessions` output, not from memory
- Run from the same project directory the session was created in
- Fall back to a new session in scripted/CI usage
When it happens
Trigger: `crush run --continue <id>` / `--last` where resolveSession(ctx, c, ws.ID, continueSessionID, useLast) cannot find the session in the SQLite store or the query errors.
Common situations: Session id typo or session belongs to a different workspace/project; database moved or deleted (fresh clone); --last used when no prior sessions exist; wrong working directory so a different workspace ID is derived.
Related errors
- cannot continue an agent tool session: %s
- session not found: %s
- cannot continue a child session: %s
- no sessions found to continue
- failed to create session for non-interactive mode: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/be7424e258aaae5c.
Report an issue: GitHub.