{"record":{"id":"89f04db2f7a8aefe","repo":"Yeachan-Heo/oh-my-codex","slug":"no-autopilot-state-found-run-omx-autopilot-start","errorCode":null,"errorMessage":"No Autopilot state found. Run `omx autopilot start --task <text>` first.","messagePattern":"No Autopilot state found\\. Run `omx autopilot start --task <text>` first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/autopilot.ts","lineNumber":132,"sourceCode":"    const state = await startMode('autopilot', task, 3, cwd, sessionId);\n    const initialized = await updateAutopilotPipelineState({\n      ...state,\n      active: true,\n      current_phase: 'deep-interview',\n      session_id: sessionId,\n      workingDirectory: cwd,\n      phase_cycle: ['deep-interview', 'ralplan', 'ultragoal'],\n      handoff_artifacts: {},\n      deep_interview_gate: { status: 'required' },\n      review_cycle: 0,\n    }, cwd, sessionId);\n    if (json) stdout(JSON.stringify({ ok: true, state: initialized, instruction: instruction(initialized) }));\n    else stdout(instruction(initialized));\n    return;\n  }\n\n  const state = await readAutopilot(cwd, sessionId);\n  if (!state) throw new Error('No Autopilot state found. Run `omx autopilot start --task <text>` first.');\n\n  if (command === 'status' || command === 'next') {\n    const nextInstruction = instruction(state);\n    const skippedGates = skippedGateReport(state as unknown as Record<string, unknown>);\n    if (json) stdout(JSON.stringify({ state, instruction: nextInstruction }));\n    else if (command === 'next') stdout(nextInstruction);\n    else stdout([skippedGates ?? `autopilot: ${state.current_phase}`, nextInstruction].join('\\n'));\n    return;\n  }\n\n  if (command === 'advance') {\n    const to = value(rest, '--to');\n    if (to !== 'ralplan' && to !== 'ultragoal') throw new Error('--to must be ralplan or ultragoal.');\n    const rawHandoff = value(rest, '--handoff-json');\n    if (!rawHandoff) throw new Error('Missing --handoff-json.');\n    const handoff = await jsonInput(rawHandoff);\n    assertBoundHandoffIdentity(handoff, cwd, sessionId);\n    const updated = await updateAutopilotPipelineState({","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/autopilot.ts#L114-L150","documentation":"Thrown when an autopilot subcommand other than start needs persisted autopilot state but readAutopilot() returns nothing for the current cwd/session. Autopilot state is created only by `autopilot start`, so any follow-up command before that fails here.","triggerScenarios":"Running `omx autopilot status`, `next`, or `advance` before ever running `autopilot start --task ...` in this workspace/session, or after state files were deleted or written under a different session id.","commonSituations":"Fresh clone or cleaned state directory, running follow-up commands in a new session (state lookup is keyed by cwd/session), or a prior start that crashed before persisting state.","solutions":["Run `omx autopilot start --task <text>` first to create the state","If you expected existing state, verify you are in the same working directory and session as when start was run","Check that state files were not removed by cleanup/git clean and re-run start if needed"],"exampleFix":"// before\nomx autopilot next\n// after\nomx autopilot start --task \"...\" && omx autopilot next","handlingStrategy":"validation","validationCode":"const state = await readAutopilotState(cwd, sessionId);\nif (!state) { await autopilotCommand(['start','--task',task]); }","typeGuard":null,"tryCatchPattern":"try { await autopilotCommand(['next']); } catch (e) { if (e.message.includes('No Autopilot state found')) { await autopilotCommand(['start','--task',task]); await autopilotCommand(['next']); } else throw e; }","preventionTips":["Always run start before status/next/advance in setup scripts","Keep state files out of clean-up patterns (gitignore hygiene)"],"tags":["cli","state-missing","autopilot"],"backgroundTag":"missing-prerequisite-state","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}