{"record":{"id":"09e24dc7bd5e4492","repo":"earendil-works/pi","slug":"already-exists","errorCode":"already_exists","errorMessage":"Session already exists: ${destination.id}","messagePattern":"Session already exists: (.+?)","errorType":"error_code","errorClass":"SessionError","httpStatus":null,"severity":"error","filePath":"packages/agent/src/harness/session/jsonl/repo.ts","lineNumber":180,"sourceCode":"\tprivate async resolveCreateDestination(options: JsonlSessionCreateOptions): Promise<{ id: string; cwd: string }> {\n\t\tconst id = options.id ?? uuidv7();\n\t\tvalidateSessionId(id);\n\t\tconst cwd = fileResult(await this.fs.absolutePath(options.cwd), `Failed to resolve session cwd ${options.cwd}`);\n\t\treturn { id, cwd };\n\t}\n\n\t/**\n\t * Prevent same-process create/fork races for one logical destination. The durable filename includes a\n\t * timestamp, so the async filesystem existence check alone can let two concurrent calls both decide the\n\t * same {cwd, id} is free and publish duplicate sessions.\n\t */\n\tprivate async claimCreateDestination<T>(\n\t\tdestination: { id: string; cwd: string },\n\t\toperation: () => Promise<T>,\n\t): Promise<T> {\n\t\tconst key = `${destination.cwd}\\0${destination.id}`;\n\t\tif (this.activeCreateDestinations.has(key)) {\n\t\t\tthrow new SessionError(\"already_exists\", `Session already exists: ${destination.id}`);\n\t\t}\n\t\tthis.activeCreateDestinations.add(key);\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} finally {\n\t\t\tthis.activeCreateDestinations.delete(key);\n\t\t}\n\t}\n\n\tprivate async prepareCreate(\n\t\tdestination: { id: string; cwd: string },\n\t\toptions: JsonlSessionCreateOptions,\n\t): Promise<{\n\t\theader: JsonlV4Header;\n\t\tpath: string;\n\t}> {\n\t\tconst { id, cwd } = destination;\n\t\tif (await this.sessionIdExists(id, cwd)) {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/agent/src/harness/session/jsonl/repo.ts#L162-L198","documentation":"Error \"Session already exists: ${destination.id}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/agent/src/harness/session/jsonl/repo.ts:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a new destination session id, or delete the existing session before copying."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}