{"record":{"id":"d1727d2623adb35f","repo":"can1357/oh-my-pi","slug":"get-subagent-messages-requires-subagentid-or-sessi","errorCode":null,"errorMessage":"get_subagent_messages requires subagentId or sessionFile","messagePattern":"get_subagent_messages requires subagentId or sessionFile","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/rpc/rpc-subagents.ts","lineNumber":263,"sourceCode":"\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":245,"sourceCodeEnd":266,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/rpc/rpc-subagents.ts#L245-L266","documentation":"resolveSessionFile requires the selector to identify a transcript somehow: either subagentId or sessionFile. If neither field is provided (both undefined/empty), it throws 'get_subagent_messages requires subagentId or sessionFile'. This is a required-argument guard on the get_subagent_messages RPC.","triggerScenarios":"Calling get_subagent_messages with an empty selector object {}, or with a selector whose subagentId and sessionFile are both undefined/null/empty strings.","commonSituations":"Generic host code that builds the selector dynamically from optional fields and forwards an empty object when neither is available; clients omitting fields because they assumed defaults.","solutions":["Always populate subagentId (preferred) or sessionFile in the selector before calling.","In dynamic callers, throw or skip the request client-side when neither field resolves.","Check field names — a typo like 'subagent_id' leaves the real field undefined."],"exampleFix":"// before\nawait rpc.getSubagentMessages({});\n// after\nawait rpc.getSubagentMessages({ subagentId: subagentId });","handlingStrategy":"validation","validationCode":"if (!selector.subagentId && !selector.sessionFile) {\n  throw new Error(\"get_subagent_messages requires subagentId or sessionFile\");\n}","typeGuard":"function isResolvableSelector(s: RpcSubagentTranscriptSelector): boolean {\n  return Boolean(s.subagentId || s.sessionFile);\n}","tryCatchPattern":"try {\n  const file = subagents.resolveSessionFile(selector);\n} catch (err) {\n  if (err instanceof Error && /requires subagentId or sessionFile/.test(err.message)) {\n    // skip request or prompt caller for a selector\n  } else throw err;\n}","preventionTips":["Type the selector so at least one of subagentId/sessionFile is required (union type).","Check field spelling (subagentId vs subagent_id) in dynamic callers.","Fail fast client-side when a dynamic selector resolves to an empty object."],"tags":["rpc","validation","required-arguments","subagents"],"backgroundTag":"missing-required-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}