{"record":{"id":"adb82cd90cb76f9f","repo":"charmbracelet/crush","slug":"no-sessions-found-to-continue","errorCode":null,"errorMessage":"no sessions found to continue","messagePattern":"no sessions found to continue","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/app/app.go","lineNumber":256,"sourceCode":"func (app *App) resolveSession(ctx context.Context, continueSessionID string, useLast bool) (session.Session, error) {\n\tswitch {\n\tcase continueSessionID != \"\":\n\t\tif app.Sessions.IsAgentToolSession(continueSessionID) {\n\t\t\treturn session.Session{}, fmt.Errorf(\"cannot continue an agent tool session: %s\", continueSessionID)\n\t\t}\n\t\tsess, err := app.Sessions.Get(ctx, continueSessionID)\n\t\tif err != nil {\n\t\t\treturn session.Session{}, fmt.Errorf(\"session not found: %s\", continueSessionID)\n\t\t}\n\t\tif sess.ParentSessionID != \"\" {\n\t\t\treturn session.Session{}, fmt.Errorf(\"cannot continue a child session: %s\", continueSessionID)\n\t\t}\n\t\treturn sess, nil\n\n\tcase useLast:\n\t\tsess, err := app.Sessions.GetLast(ctx)\n\t\tif err != nil {\n\t\t\treturn session.Session{}, fmt.Errorf(\"no sessions found to continue\")\n\t\t}\n\t\treturn sess, nil\n\n\tdefault:\n\t\treturn app.Sessions.Create(ctx, agent.DefaultSessionName)\n\t}\n}\n\n// RunNonInteractive runs the application in non-interactive mode with the\n// given prompt, printing to stdout.\nfunc (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt, largeModel, smallModel string, hideSpinner bool, continueSessionID string, useLast bool) error {\n\tslog.Info(\"Running in non-interactive mode\")\n\n\t// Re-initialize the coder agent without interactive-only tools.\n\tif err := app.InitCoderAgentNonInteractive(ctx); err != nil {\n\t\treturn fmt.Errorf(\"failed to reinitialize agent for non-interactive mode: %w\", err)\n\t}\n","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/app/app.go#L238-L274","documentation":"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.","triggerScenarios":"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.","commonSituations":"First run of crush in a new repo; cleaned ~/.local/share/crush data; switching machines/containers without persisted state; scripts that always pass --continue.","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."],"exampleFix":"// before\ncrush run --continue \"hello\"   # empty history -> fails\n\n// after\ncrush run \"hello\"              # creates a new session","handlingStrategy":"fallback","validationCode":"if _, err := app.Sessions.GetLast(ctx); err != nil {\n    // no sessions yet — create one instead of continuing\n}","typeGuard":null,"tryCatchPattern":"sess, err := app.resolveSession(ctx, \"\", true)\nif err != nil && strings.Contains(err.Error(), \"no sessions found to continue\") {\n    sess, err = app.Sessions.Create(ctx, agent.DefaultSessionName)\n}","preventionTips":["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."],"tags":["go","session","cli","empty-state"],"backgroundTag":"no-sessions-found","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}