{"record":{"id":"d3601835fdffb27d","repo":"can1357/oh-my-pi","slug":"no-active-checkpoint-create-a-checkpoint-before-c","errorCode":null,"errorMessage":"No active checkpoint. Create a checkpoint before calling rewind.","messagePattern":"No active checkpoint\\. Create a checkpoint before calling rewind\\.","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/checkpoint.ts","lineNumber":121,"sourceCode":"\n\tstatic createIf(session: ToolSession): RewindTool | null {\n\t\treturn new RewindTool(session);\n\t}\n\n\tasync execute(\n\t\t_toolCallId: string,\n\t\tparams: RewindParams,\n\t\t_signal?: AbortSignal,\n\t\t_onUpdate?: AgentToolUpdateCallback<RewindToolDetails>,\n\t\t_context?: AgentToolContext,\n\t): Promise<AgentToolResult<RewindToolDetails>> {\n\t\tif (!this.session.getCheckpointState?.()) {\n\t\t\tif (this.session.getLastCompletedRewind?.()) {\n\t\t\t\tthrow new ToolError(\n\t\t\t\t\t\"Checkpoint already completed; continue from the retained rewind report instead of calling rewind again.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new ToolError(\"No active checkpoint. Create a checkpoint before calling rewind.\");\n\t\t}\n\t\tconst report = params.report.trim();\n\t\tif (report.length === 0) {\n\t\t\tthrow new ToolError(\"Report cannot be empty.\");\n\t\t}\n\t\treturn toolResult<RewindToolDetails>({ report, rewound: true })\n\t\t\t.text([\"Rewind requested.\", \"Report captured for context replacement.\"].join(\"\\n\"))\n\t\t\t.done();\n\t}\n}\n","sourceCodeStart":103,"sourceCodeEnd":132,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/checkpoint.ts#L103-L132","documentation":"The rewind tool requires an active checkpoint to rewind to. If session.getCheckpointState() returns nothing and no rewind has previously completed, there is no snapshot to restore, so the tool throws immediately. A checkpoint tool call must precede any rewind in the session.","triggerScenarios":"Calling the rewind tool's execute() before any checkpoint tool call was made, or after the checkpoint state was never initialized in the session.","commonSituations":"An agent emits the rewind tool call without first emitting checkpoint; a session was restarted and checkpoint state was not persisted; a test or script invokes rewind directly on a fresh ToolSession.","solutions":["Call the checkpoint tool first to create a snapshot, then call rewind.","Verify checkpoint state exists with session.getCheckpointState() before scheduling a rewind.","If state was expected, check whether the session was recreated or checkpoint state failed to persist."],"exampleFix":"// before\nawait session.tools.rewind({ report: \"restore files\" });\n\n// after\nif (!session.getCheckpointState?.()) {\n  await session.tools.checkpoint();\n}\nawait session.tools.rewind({ report: \"restore files\" });","handlingStrategy":"validation","validationCode":"if (!session.getCheckpointState?.()) {\n  await session.tools.checkpoint(); // create snapshot first\n}","typeGuard":null,"tryCatchPattern":"try {\n  await rewindTool.execute(params, ...);\n} catch (err) {\n  if (err instanceof ToolError && /No active checkpoint/.test(err.message)) {\n    await session.tools.checkpoint();\n    await rewindTool.execute(params, ...); // retry once after checkpointing\n  } else throw err;\n}","preventionTips":["Always pair checkpoint → rewind in workflow code.","Assert checkpoint state exists in tests before exercising rewind.","Persist/restore checkpoint state across session restarts if rewinds must survive restarts."],"tags":["checkpoint","rewind","missing-state","tool-error"],"backgroundTag":"no-active-checkpoint","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}