{"record":{"id":"e30c8962bdc2de53","repo":"can1357/oh-my-pi","slug":"unsupported-rpc-session-change-command","errorCode":null,"errorMessage":"Unsupported RPC session change command","messagePattern":"Unsupported RPC session change command","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/rpc/rpc-mode.ts","lineNumber":494,"sourceCode":"\t\t\tconst options = command.parentSession ? { parentSession: command.parentSession } : undefined;\n\t\t\tconst cancelled = !(await session.newSession(options));\n\t\t\tif (!cancelled) subagentRegistry?.clear();\n\t\t\treturn { type: \"new_session\", data: { cancelled } };\n\t\t}\n\n\t\tcase \"switch_session\": {\n\t\t\tconst cancelled = !(await session.switchSession(command.sessionPath));\n\t\t\tif (!cancelled) subagentRegistry?.clear();\n\t\t\treturn { type: \"switch_session\", data: { cancelled } };\n\t\t}\n\n\t\tcase \"branch\": {\n\t\t\tconst result = await session.branch(command.entryId);\n\t\t\tif (!result.cancelled) subagentRegistry?.clear();\n\t\t\treturn { type: \"branch\", data: { text: result.selectedText, cancelled: result.cancelled } };\n\t\t}\n\t}\n\tthrow new Error(\"Unsupported RPC session change command\");\n}\n\nfunction normalizeHostToolDefinitions(tools: RpcHostToolDefinition[]): RpcHostToolDefinition[] {\n\treturn tools.map((tool, index) => {\n\t\tconst name = typeof tool.name === \"string\" ? tool.name.trim() : \"\";\n\t\tif (!name) {\n\t\t\tthrow new Error(`Host tool at index ${index} must provide a non-empty name`);\n\t\t}\n\t\tconst description = typeof tool.description === \"string\" ? tool.description.trim() : \"\";\n\t\tif (!description) {\n\t\t\tthrow new Error(`Host tool \"${name}\" must provide a non-empty description`);\n\t\t}\n\t\tif (!tool.parameters || typeof tool.parameters !== \"object\" || Array.isArray(tool.parameters)) {\n\t\t\tthrow new Error(`Host tool \"${name}\" must provide a JSON Schema object`);\n\t\t}\n\t\tconst label = typeof tool.label === \"string\" && tool.label.trim() ? tool.label.trim() : name;\n\t\treturn {\n\t\t\tname,","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/rpc/rpc-mode.ts#L476-L512","documentation":"handleRpcSessionChange dispatches RPC session-change commands (e.g. 'branch') via a switch. If the command's type is not one of the known session change operations, the switch falls through and the function throws 'Unsupported RPC session change command'. It is a protocol-level guard against unknown or newer command types sent to an older host.","triggerScenarios":"Sending an RPC request whose session-change command type is misspelled, not implemented in this version, or added by a newer client than the running host, so no case in the switch matches.","commonSituations":"Version skew between an RPC client SDK and the omp host (client sends a new command the host doesn't know); a typo in the command name in custom tooling or scripts driving the RPC interface.","solutions":["Check the command name sent over RPC for typos and confirm it is one of the supported session change commands (e.g. 'branch').","Upgrade the omp host (or client) so both sides support the command type.","Wrap the RPC dispatch in a handler that maps unknown-command errors to a clean 'unsupported command' response for the client."],"exampleFix":"// before\nawait rpc.request(\"session.change\", { command: \"braanch\", entryId });\n// after\nawait rpc.request(\"session.change\", { command: \"branch\", entryId });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"branch\"]);\nif (!SUPPORTED.has(command.type)) throw new Error(`Unsupported session change command: ${command.type}`);","typeGuard":"function isSessionChangeCommand(cmd: string): cmd is \"branch\" {\n  return cmd === \"branch\";\n}","tryCatchPattern":"try {\n  await rpc.sessionChange(command);\n} catch (err) {\n  if (err instanceof Error && err.message === \"Unsupported RPC session change command\") {\n    // surface a clean unsupported-command response to the client\n  } else throw err;\n}","preventionTips":["Keep client and host versions in sync; check feature availability before sending new command types.","Centralize the list of valid command names in a shared constant instead of inline strings.","Log the exact command payload when this fires to catch typos quickly."],"tags":["rpc","protocol","unknown-command","version-skew"],"backgroundTag":"unsupported-rpc-command","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}