{"record":{"id":"24b26624b6bbc8bc","repo":"can1357/oh-my-pi","slug":"unknown-subagent-session-file","errorCode":null,"errorMessage":"Unknown subagent session file","messagePattern":"Unknown subagent session file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/rpc/rpc-subagents.ts","lineNumber":260,"sourceCode":"\thandleEvent(payload: SubagentEventPayload): void {\n\t\tif (this.#staleSubagentIds.has(payload.id)) return;\n\t\tif (this.#subscriptionLevel !== \"events\") return;\n\t\tthis.#output({ type: \"subagent_event\", payload } satisfies RpcSubagentEventFrame);\n\t}\n\n\tresolveSessionFile(selector: RpcSubagentTranscriptSelector): string {\n\t\tif (selector.subagentId) {\n\t\t\tconst snapshot = this.#subagents.get(selector.subagentId);\n\t\t\tconst sessionFile = snapshot?.sessionFile ?? this.#transcriptSessionFilesBySubagentId.get(selector.subagentId);\n\t\t\tif (!sessionFile) {\n\t\t\t\tthrow new Error(`Unknown subagent or session file unavailable: ${selector.subagentId}`);\n\t\t\t}\n\t\t\treturn sessionFile;\n\t\t}\n\n\t\tif (selector.sessionFile) {\n\t\t\tif (this.#hasTranscriptSessionFile(selector.sessionFile)) return selector.sessionFile;\n\t\t\tthrow new Error(\"Unknown subagent session file\");\n\t\t}\n\n\t\tthrow new Error(\"get_subagent_messages requires subagentId or sessionFile\");\n\t}\n}\n","sourceCodeStart":242,"sourceCodeEnd":266,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/rpc/rpc-subagents.ts#L242-L266","documentation":"resolveSessionFile accepts an explicit sessionFile in the selector, but only if that file is part of the transcript's known session files (checked by #hasTranscriptSessionFile). Passing a path the transcript does not recognize throws 'Unknown subagent session file', preventing reads of arbitrary or untracked session files through this RPC surface.","triggerScenarios":"Passing selector.sessionFile set to a path that was never registered as a subagent session in the current transcript — e.g. an absolute path to a session from another project, a renamed/moved file, or a fabricated path.","commonSituations":"Pointing the selector at a main-session file instead of a subagent session file; constructing the path by hand rather than using an ID returned by the subagent APIs; sessions moved between machines where the recorded paths differ.","solutions":["Use the sessionFile path that was returned when the subagent was created, not a hand-built path.","Prefer selector.subagentId so the resolver looks up the correct registered file.","Verify the file belongs to the current transcript/session before calling."],"exampleFix":"// before\nsubagents.resolveSessionFile({ sessionFile: \"/tmp/other-project/session.jsonl\" });\n// after\nsubagents.resolveSessionFile({ subagentId: spawnedSubagent.id });","handlingStrategy":"validation","validationCode":"// only pass session files that were obtained from this session's subagent records\nif (!sessionFileFromSubagentRecord) throw new Error(\"refusing to resolve hand-built session path\");","typeGuard":null,"tryCatchPattern":"try {\n  const file = subagents.resolveSessionFile({ sessionFile });\n} catch (err) {\n  if (err instanceof Error && err.message === \"Unknown subagent session file\") {\n    // retry via subagentId or report the untracked file\n  } else throw err;\n}","preventionTips":["Never construct session file paths manually; use paths returned by subagent spawn results.","Use subagentId selectors so the resolver finds the registered file.","Remember paths are transcript-scoped; files from other sessions/projects are rejected."],"tags":["rpc","subagents","validation","file-path"],"backgroundTag":"unknown-subagent-id","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}