{"record":{"id":"17c38f9a02890ac4","repo":"charmbracelet/crush","slug":"cannot-continue-a-child-session-s","errorCode":null,"errorMessage":"cannot continue a child session: %s","messagePattern":"cannot continue a child session: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":249,"sourceCode":"\tapp.herdrClient.SetSessionID(sessionID)\n}\n\n// resolveSession resolves which session to use for a non-interactive run\n// If continueSessionID is set, it looks up that session by ID\n// If useLast is set, it returns the most recently updated top-level session\n// Otherwise, it creates a new session\nfunc (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 {","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/app/app.go#L231-L267","documentation":"The referenced session exists but has a non-empty ParentSessionID, meaning it is a child session (created for a sub-task or fork). Continuation is only supported for top-level sessions, so resolveSession refuses to resume a child directly.","triggerScenarios":"Running with continueSessionID set to a child/forked session ID — the session was created as part of a task/fork flow and carries a parent reference.","commonSituations":"Picking the newest row from the sessions table without filtering by ParentSessionID; intentionally trying to resume a sub-agent conversation; UIs that show child sessions alongside parent ones.","solutions":["Continue the parent session ID (sess.ParentSessionID) instead of the child.","Filter session listings to top-level sessions (ParentSessionID == \"\") when scripting.","Start a fresh session if the child context must be re-run standalone."],"exampleFix":"// before\ncrush run --continue <child-session-id> \"continue\"\n\n// after\ncrush run --continue <parent-session-id> \"continue\"","handlingStrategy":"validation","validationCode":"sess, err := app.Sessions.Get(ctx, sessionID)\nif err == nil && sess.ParentSessionID != \"\" {\n    return fmt.Errorf(\"%s is a child session; continue %s instead\", sessionID, sess.ParentSessionID)\n}","typeGuard":"func isTopLevel(s session.Session) bool { return s.ParentSessionID == \"\" }","tryCatchPattern":"if err != nil {\n    if strings.HasPrefix(err.Error(), \"cannot continue a child session\") {\n        // look up sess.ParentSessionID and retry with it\n    }\n    return err\n}","preventionTips":["Filter session listings to ParentSessionID == \"\" when selecting sessions to resume.","Treat child sessions as internal implementation detail of task/fork flows."],"tags":["go","session","hierarchy","cli"],"backgroundTag":"invalid-session-resume","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}