{"record":{"id":"439069802ee62348","repo":"charmbracelet/crush","slug":"cannot-continue-a-child-session-s-439069","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/cmd/run.go","lineNumber":680,"sourceCode":"\t\t\tlabel, modelID, strings.Join(names, \", \"),\n\t\t)\n\t}\n\treturn matches[0], nil\n}\n\n// resolveSession returns the session to use for a non-interactive run.\n// If continueSessionID is set it fetches that session; if useLast is set it\n// returns the most recently updated top-level session; otherwise it creates a\n// new one.\nfunc resolveSession(ctx context.Context, c *client.Client, wsID, continueSessionID string, useLast bool) (*proto.Session, error) {\n\tswitch {\n\tcase continueSessionID != \"\":\n\t\tsess, err := c.GetSession(ctx, wsID, continueSessionID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"session not found: %s\", continueSessionID)\n\t\t}\n\t\tif sess.ParentSessionID != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"cannot continue a child session: %s\", continueSessionID)\n\t\t}\n\t\treturn sess, nil\n\n\tcase useLast:\n\t\tsessions, err := c.ListSessions(ctx, wsID)\n\t\tif err != nil || len(sessions) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"no sessions found to continue\")\n\t\t}\n\t\tlast := sessions[0]\n\t\tfor _, s := range sessions[1:] {\n\t\t\tif s.UpdatedAt > last.UpdatedAt && s.ParentSessionID == \"\" {\n\t\t\t\tlast = s\n\t\t\t}\n\t\t}\n\t\treturn &last, nil\n\n\tdefault:\n\t\treturn c.CreateSession(ctx, wsID, \"non-interactive\")","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/run.go#L662-L698","documentation":"After a session is fetched successfully, resolveSession rejects it if ParentSessionID is non-empty. Child sessions are created for sub-agents/tasks spawned from a parent run and are not meant to be resumed directly, so continuing one is blocked with this error.","triggerScenarios":"Calling `crush run --continue <childSessionID>` where the session record has a non-empty ParentSessionID, i.e. the ID belongs to a task/sub-agent session rather than a top-level session.","commonSituations":"Copying a session ID from a child task in the session list or logs instead of the parent; picking the wrong row when several sessions share a similar name; scripting against session IDs harvested from internal message records.","solutions":["Find the parent session ID (the child's ParentSessionID field) and pass that to --continue instead.","List sessions and choose one without a parent (a top-level session).","If you need the child's context, resume the parent session which contains the child's history."],"exampleFix":"// before\ncrush run --continue <child-session-id> \"continue\"\n// after\n# resume the parent of that child session instead\ncrush run --continue <parent-session-id> \"continue\"","handlingStrategy":"validation","validationCode":"sess, err := c.GetSession(ctx, wsID, contID)\nif err == nil && sess.ParentSessionID != \"\" {\n    return fmt.Errorf(\"refusing to continue child session %s; use parent %s\", contID, sess.ParentSessionID)\n}","typeGuard":"func isTopLevel(s proto.Session) bool { return s.ParentSessionID == \"\" }","tryCatchPattern":"sess, err := resolveSession(ctx, c, wsID, contID, false)\nif err != nil && strings.HasPrefix(err.Error(), \"cannot continue a child session:\") {\n    // resolve the parent and retry\n    parentID := childToParent[contID]\n    sess, err = resolveSession(ctx, c, wsID, parentID, false)\n}","preventionTips":["Filter session lists to ParentSessionID == \"\" before offering IDs for --continue.","Store parent IDs, not child/task IDs, in scripts and CI workflows."],"tags":["cli","session","child-session"],"backgroundTag":"child-session-not-resumable","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}