different-ai/openwork · error · Error
serializeSDKError(result.error)
Error message
serializeSDKError(result.error)
What it means
When a slash-command draft is submitted, the UI calls opencodeClient.session.command() against the primary endpoint. The SDK returns a result envelope; a non-null result.error means the server rejected the command. The UI serializes that SDK error (serializeSDKError, session-route.tsx:254) into a thrown Error so it surfaces in the normal send-error path.
Source
Thrown at apps/app/src/react-app/shell/session-route.tsx:1341
label: modelSelection,
},
];
trackSessionActive(targetSessionId, telemetryDimensions);
trackTaskStarted(targetSessionId, telemetryDimensions);
if (draft.mode === "shell") {
await shellInSession(opencodeClient, targetSessionId, text);
return;
}
if (draft.command) {
const result = await opencodeClient.session.command({
sessionID: targetSessionId,
command: draft.command.name,
arguments: draft.command.arguments,
});
if (result.error) {
throw new Error(serializeSDKError(result.error));
}
return;
}
const parts = await draftToParts(draft, selectedWorkspaceRoot, targetSessionId, selectedWorkspaceEndpoint);
const envSystemContext = await buildOpenworkEnvSystemContext(client, {
cacheKey: targetSessionId,
runtimeKey: environmentRuntimeKey,
});
const result = await opencodeClient.session.promptAsync({
sessionID: targetSessionId,
parts,
model: sendModel ?? undefined,
agent: selectedAgent ?? undefined,
...(sendVariant ? { variant: sendVariant } : {}),
...(envSystemContext ? { system: envSystemContext } : {}),
});
if (result.error) {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Read the serialized error text for the server's reason (unknown command vs. execution failure)
- Verify the command name exists in the workspace's command configuration
- Check the session still exists and retry; start a new session if it was deleted
- Update the app if the client and server versions are mismatched
Defensive patterns
Strategy: try-catch
Validate before calling
const known = await opencodeClient.command.list();
if (!known.data?.some((c) => c.name === draft.command.name)) {
notify(`Unknown command: ${draft.command.name}`);
return;
} Try / catch
try {
const result = await opencodeClient.session.command({ sessionID, command, arguments });
if (result.error) throw new Error(serializeSDKError(result.error));
} catch (e) {
showErrorToast(String((e as Error).message));
} Prevention
- Validate command names against the server's command list before submit
- Keep client and server versions in sync
- Confirm the session exists before sending commands
When it happens
Trigger: Submitting a draft with draft.command set where opencodeClient.session.command() returns { error } — unknown command name, command failed server-side, invalid arguments, or session no longer exists.
Common situations: Typing a custom command that the server's command list no longer defines; passing wrong-typed arguments to a command; session was reverted/deleted between draft and submit; server version mismatch after an app update.
Related errors
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/100537b62d021e24.
Report an issue: GitHub.