{"record":{"id":"65f76354429dd07f","repo":"can1357/oh-my-pi","slug":"agent-ref-id-has-no-transcript-session-is-gone","errorCode":null,"errorMessage":"Agent ${ref.id} has no transcript: session is gone and no session file was retained","messagePattern":"Agent (.+?) has no transcript: session is gone and no session file was retained","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/history-protocol.ts","lineNumber":120,"sourceCode":"\t\t\tconst known = visible.map(candidate => candidate.id);\n\t\t\tconst knownStr = known.length > 0 ? known.join(\", \") : \"none\";\n\t\t\tthrow new Error(`Unknown agent: ${agentId}\\nKnown agents: ${knownStr}\\nList all with history://`);\n\t\t}\n\n\t\tconst notes: string[] = [];\n\t\tlet messages: unknown[];\n\t\tif (ref.session) {\n\t\t\tmessages = ref.session.messages;\n\t\t\tnotes.push(\"Source: live session\");\n\t\t} else if (ref.sessionFile) {\n\t\t\tmessages = await loadSessionMessagesReadOnly(ref.sessionFile);\n\t\t\tnotes.push(`Source: session file (read-only, ${ref.status})`);\n\t\t} else {\n\t\t\t// No live session and no retained sessionFile — try the disk scan before\n\t\t\t// giving up, in case the transcript lingers under an artifacts dir.\n\t\t\tconst disk = await this.#resolveFromDisk(ref.id, preferredArtifactDir);\n\t\t\tif (disk) return { ...disk, url: url.href };\n\t\t\tthrow new Error(`Agent ${ref.id} has no transcript: session is gone and no session file was retained`);\n\t\t}\n\n\t\tconst content = formatSessionHistoryMarkdown(messages, { title: `${ref.id} (${ref.status})` });\n\t\treturn {\n\t\t\turl: url.href,\n\t\t\tcontent,\n\t\t\tcontentType: \"text/markdown\",\n\t\t\tsize: Buffer.byteLength(content, \"utf-8\"),\n\t\t\tsourcePath: ref.sessionFile ?? undefined,\n\t\t\tnotes,\n\t\t};\n\t}\n\n\t/**\n\t * Load a transcript for `agentId` from an on-disk `.jsonl` session file,\n\t * matched case-insensitively. Returns `undefined` when no file is found.\n\t * `preferredArtifactDir` — the caller root's artifact directory, when\n\t * known — is scanned before every registry-derived dir, so a same-id","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/history-protocol.ts#L102-L138","documentation":"An agent id is known (it appears in the agent registry) but has no retrievable transcript: the live session is gone and no session file path was retained, and the disk scan found nothing. resolve throws rather than returning an empty history.","triggerScenarios":"history://<agentId> for an agent whose session ended without sessionFile retention (e.g. aborted before first persist, or session file deleted) and #resolveFromDisk found no retained file under any artifacts dir.","commonSituations":"Requesting history for an agent that crashed very early; sessions cleaned by retention policy; running across machines where the artifacts dir differs.","solutions":["Accept the transcript is unrecoverable and query a different agent/session","Check the artifacts directory manually for orphaned session files","Enable/disable retention settings so future sessions persist their session file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await resolve(`history://${agentId}`)\n} catch (err) {\n  if (String(err).includes('has no transcript')) {\n    logger.warn('transcript unrecoverable', { agentId })\n    return null\n  }\n  throw err\n}","preventionTips":["Read transcripts while the session is still live or shortly after completion","Enable session-file retention for agents you may inspect later","Back up the artifacts directory before cleanup runs"],"tags":["history","missing-transcript","session"],"backgroundTag":"transcript-unavailable","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}