{"record":{"id":"c9134529ae402912","repo":"can1357/oh-my-pi","slug":"checkpoint-already-active","errorCode":null,"errorMessage":"Checkpoint already active.","messagePattern":"Checkpoint already active\\.","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/checkpoint.ts","lineNumber":80,"sourceCode":"\treadonly intent = (args: Partial<CheckpointParams>) => (args.goal ? `checkpointing: ${args.goal}` : \"checkpointing\");\n\n\tconstructor(private readonly session: ToolSession) {\n\t\tthis.description = prompt.render(checkpointDescription);\n\t}\n\n\tstatic createIf(session: ToolSession): CheckpointTool | null {\n\t\treturn new CheckpointTool(session);\n\t}\n\n\tasync execute(\n\t\t_toolCallId: string,\n\t\tparams: CheckpointParams,\n\t\t_signal?: AbortSignal,\n\t\t_onUpdate?: AgentToolUpdateCallback<CheckpointToolDetails>,\n\t\t_context?: AgentToolContext,\n\t): Promise<AgentToolResult<CheckpointToolDetails>> {\n\t\tif (this.session.getCheckpointState?.()) {\n\t\t\tthrow new ToolError(\"Checkpoint already active.\");\n\t\t}\n\t\tconst startedAt = new Date().toISOString();\n\t\treturn toolResult<CheckpointToolDetails>({ goal: params.goal, startedAt })\n\t\t\t.text([`Checkpoint: ${params.goal}`, \"Finish exploration and formulate findings.\"].join(\"\\n\"))\n\t\t\t.done();\n\t}\n}\n\nexport class RewindTool implements AgentTool<typeof rewindSchema, RewindToolDetails> {\n\treadonly name = \"rewind\";\n\treadonly approval = \"read\" as const;\n\treadonly label = \"Rewind\";\n\treadonly summary = \"Rewind to a previously created checkpoint\";\n\treadonly description: string;\n\treadonly parameters = rewindSchema;\n\treadonly strict = true;\n\treadonly loadMode = \"discoverable\";\n\treadonly intent = (): string => \"rewinding\";","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/checkpoint.ts#L62-L98","documentation":"The checkpoint tool allows only one active checkpoint per session. execute() checks session.getCheckpointState() and throws this ToolError if a checkpoint is already running — checkpoints are exclusive because they frame an exploration-to-findings workflow.","triggerScenarios":"Calling checkpoint.start (or execute) while a previous checkpoint was started and never cleared; agent retrying the tool after a partial failure that left state set; two agents/subtasks sharing one session each starting a checkpoint.","commonSituations":"Workflow script that starts a checkpoint but aborts before finishing it; user manually re-running a checkpoint step in an interactive session; long-running checkpoint from a prior task still active when a new task begins.","solutions":["Finish or clear the active checkpoint before starting a new one","Check session.getCheckpointState() before calling the tool to see the existing goal/startedAt","Reset the session (or its checkpoint state) if the prior checkpoint is orphaned from an aborted run","Serialize checkpoint usage: one checkpoint per session at a time"],"exampleFix":"// before\nawait checkpointTool.execute({ goal: 'explore auth' }) // second call\n// after\nif (!session.getCheckpointState?.()) {\n\tawait checkpointTool.execute({ goal: 'explore auth' });\n}","handlingStrategy":"validation","validationCode":"const state = session.getCheckpointState?.();\nif (state) throw new Error(`checkpoint already active: ${state.goal}`);","typeGuard":null,"tryCatchPattern":"try {\n\tawait checkpointTool.execute({ goal }, ...);\n} catch (err) {\n\tif (err instanceof ToolError && /already active/.test(err.message)) {\n\t\t// resolve or clear the existing checkpoint, then retry\n\t} else throw err;\n}","preventionTips":["Check session.getCheckpointState() before starting a checkpoint","Always finish/clear a checkpoint when its task ends, including abort paths","One checkpoint per session; serialize across agents sharing a session","Reset orphaned checkpoint state after failed runs"],"tags":["state-conflict","checkpoint","session"],"backgroundTag":"operation-already-active","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}