charmbracelet/crush · warning
no sessions found to continue
Error message
no sessions found to continue
What it means
With useLast set (e.g. --continue with no explicit ID), resolveSession calls Sessions.GetLast; when the sessions table is empty (or the query errors), it returns this message. There is no prior conversation to continue in this project's data directory.
Source
Thrown at internal/app/app.go:256
func (app *App) resolveSession(ctx context.Context, continueSessionID string, useLast bool) (session.Session, error) {
switch {
case continueSessionID != "":
if app.Sessions.IsAgentToolSession(continueSessionID) {
return session.Session{}, fmt.Errorf("cannot continue an agent tool session: %s", continueSessionID)
}
sess, err := app.Sessions.Get(ctx, continueSessionID)
if err != nil {
return session.Session{}, fmt.Errorf("session not found: %s", continueSessionID)
}
if sess.ParentSessionID != "" {
return session.Session{}, fmt.Errorf("cannot continue a child session: %s", continueSessionID)
}
return sess, nil
case useLast:
sess, err := app.Sessions.GetLast(ctx)
if err != nil {
return session.Session{}, fmt.Errorf("no sessions found to continue")
}
return sess, nil
default:
return app.Sessions.Create(ctx, agent.DefaultSessionName)
}
}
// RunNonInteractive runs the application in non-interactive mode with the
// given prompt, printing to stdout.
func (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt, largeModel, smallModel string, hideSpinner bool, continueSessionID string, useLast bool) error {
slog.Info("Running in non-interactive mode")
// Re-initialize the coder agent without interactive-only tools.
if err := app.InitCoderAgentNonInteractive(ctx); err != nil {
return fmt.Errorf("failed to reinitialize agent for non-interactive mode: %w", err)
}
View on GitHub (pinned to 7944b8e522)
Solutions
- Run without the continue flag to create a new session.
- Create a session first (any run) then use continue on subsequent invocations.
- If sessions should exist, verify the correct data directory is being used (same user/home/project).
- In scripts, fall back to a new session when GetLast/continue fails.
Example fix
// before crush run --continue "hello" # empty history -> fails // after crush run "hello" # creates a new session
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := app.Sessions.GetLast(ctx); err != nil {
// no sessions yet — create one instead of continuing
} Try / catch
sess, err := app.resolveSession(ctx, "", true)
if err != nil && strings.Contains(err.Error(), "no sessions found to continue") {
sess, err = app.Sessions.Create(ctx, agent.DefaultSessionName)
} Prevention
- In scripts, attempt continue and fall back to creating a new session on failure.
- Do not assume history exists in fresh clones, CI containers, or after data cleanup.
- Verify the same HOME/data directory is used across runs if persistence is expected.
When it happens
Trigger: Running the CLI with a 'continue last session' flag in a fresh project/directory, after deleting the database, or in CI environments where no session has ever been created.
Common situations: First run of crush in a new repo; cleaned ~/.local/share/crush data; switching machines/containers without persisted state; scripts that always pass --continue.
Related errors
- cannot continue an agent tool session: %s
- session not found: %s
- cannot continue a child session: %s
- failed to resolve session: %w
- no sessions found to continue
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/adb82cd90cb76f9f.
Report an issue: GitHub.