{"record":{"id":"d54b4152c4685365","repo":"can1357/oh-my-pi","slug":"unknown-agent-agentid-nknown-agents-knownst","errorCode":null,"errorMessage":"Unknown agent: ${agentId}\\nKnown agents: ${knownStr}\\nList all with history://","messagePattern":"Unknown agent: (.+?)\\\\nKnown agents: (.+?)\\\\nList all with history://","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/history-protocol.ts","lineNumber":104,"sourceCode":"\t\t}\n\n\t\tlet ref = registry.get(agentId);\n\t\tif (ref?.kind === \"advisor\") ref = undefined;\n\t\tif (!ref) {\n\t\t\t// Case-insensitive fallback: agent ids are human-typed (e.g. AuthLoader).\n\t\t\tconst lower = agentId.toLowerCase();\n\t\t\tref = visible.find(candidate => candidate.id.toLowerCase() === lower);\n\t\t}\n\n\t\tif (!ref) {\n\t\t\t// Registry miss — the agent may have been unregistered or lost on resume.\n\t\t\t// Serve its transcript straight from disk if the session file persists.\n\t\t\tconst disk = await this.#resolveFromDisk(agentId, preferredArtifactDir);\n\t\t\tif (disk) return { ...disk, url: url.href };\n\n\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","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/history-protocol.ts#L86-L122","documentation":"history://<agentId> resolves an agent to a live session or a retained session file. If the agent id matches no visible agent and no transcript can be recovered from disk, resolve throws listing the known agent ids and pointing to history:// for the full list.","triggerScenarios":"Calling history://<agentId> (via resolve) with an id that is neither a live/known agent nor recoverable from the artifacts directory scan.","commonSituations":"Typo'd or shortened agent id; referencing an agent from a previous process run whose session file was deleted; confusing session ids with agent ids.","solutions":["Use one of the 'Known agents: ...' ids from the message","Call history:// (no id) to list all agents and copy the exact id","If the transcript matters, locate the session file manually before it is cleaned up"],"exampleFix":"// before\nawait resolve('history://agnt_12')\n// after\nawait resolve('history://agent_12ab') // exact id from history:// listing","handlingStrategy":"validation","validationCode":"const agents = await resolve('history://') // list\nconst ids = extractAgentIds(agents)\nif (!ids.includes(agentId)) throw new Error(`unknown agent ${agentId}; known: ${ids.join(', ')}`)","typeGuard":null,"tryCatchPattern":"try {\n  return await resolve(`history://${agentId}`)\n} catch (err) {\n  if (String(err).startsWith('Unknown agent:')) {\n    const list = await resolve('history://')\n    logger.warn('agent not found, listing known', { agentId })\n    return list\n  }\n  throw err\n}","preventionTips":["Copy agent ids from the history:// listing, never from memory","Resolve transcripts within the same process/session that created the agent","Retain session files for agents you plan to inspect later"],"tags":["history","unknown-agent","internal-url"],"backgroundTag":"resource-id-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}