{"record":{"id":"766a0646a5ea3655","repo":"different-ai/openwork","slug":"the-desktop-runtime-is-unavailable","errorCode":null,"errorMessage":"The desktop runtime is unavailable","messagePattern":"The desktop runtime is unavailable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/electron/automation-runner.mjs","lineNumber":152,"sourceCode":"  const workspaces = Array.isArray(listed?.items) ? listed.items : []\n  if (pinnedWorkspaceId) {\n    const pinned = workspaces.find((item) => item?.id === pinnedWorkspaceId)\n    if (!pinned?.id) {\n      const error = new Error(`The Automation's pinned workspace is not available on this desktop`)\n      Object.defineProperty(error, \"code\", { value: \"execution_runtime_unavailable\" })\n      throw error\n    }\n    return pinned\n  }\n  const workspace = workspaces.find((item) => item?.id === listed?.activeId) ?? workspaces[0]\n  if (!workspace?.id) throw new Error(\"No local workspace is available\")\n  return workspace\n}\n\n/** Runs the assignment as a normal visible local OpenWork thread. */\nexport async function executeDesktopAutomation(assignment, options) {\n  const local = await options.getLocalRuntime()\n  if (!local?.baseUrl || !local?.token) throw new Error(\"The desktop runtime is unavailable\")\n  const localRequest = (requestPath, request = {}) => requestJson(\n    options.fetchImpl ?? fetch,\n    local.baseUrl,\n    local.token,\n    requestPath,\n    { ...request, signal: options.signal },\n  )\n  const listed = await localRequest(\"/workspaces\")\n  const workspace = resolveAssignmentWorkspace(listed, assignment.workspaceId ?? null)\n  const workspaceId = String(workspace.id)\n  const client = createWorkspaceSessionClient(local, workspaceId, options.fetchImpl ?? fetch)\n  const created = await client.createThread({\n    title: `Automation: ${assignment.automationName}`.slice(0, 120),\n    ...(assignment.instructions ? { prompt: assignment.instructions } : {}),\n    model: assignment.model,\n    signal: options.signal,\n  })\n  const sessionId = created.id","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/automation-runner.mjs#L134-L170","documentation":"executeDesktopAutomation needs a local runtime descriptor with both baseUrl and an auth token to talk to the local OpenWork server. getLocalRuntime() returned null/undefined or an object missing either field, so no HTTP client can be built and execution is aborted immediately with this error.","triggerScenarios":"options.getLocalRuntime() resolves to null, or returns `{}`/`{ baseUrl }`/`{ token }` — i.e. the Electron main process has no connection info for the local server when an automation assignment starts.","commonSituations":"Server not started before automations run; server connection dropped but runtime cache not refreshed; token cleared after sign-out while scheduled automations still fire.","solutions":["Ensure the local OpenWork server is running and the desktop app is connected before automations execute","Reconnect/sign in to regenerate the runtime token","Make getLocalRuntime() await server readiness (retry until baseUrl+token present)","Skip/park scheduled assignments when runtime is unavailable instead of executing"],"exampleFix":"// before\nconst local = await options.getLocalRuntime();\nif (!local?.baseUrl || !local?.token) throw new Error(\"The desktop runtime is unavailable\");\n// after: ensure connection before executing\nlet local = await options.getLocalRuntime();\nif (!local?.baseUrl || !local?.token) local = await reconnectLocalRuntime();\nif (!local?.baseUrl || !local?.token) throw new Error(\"The desktop runtime is unavailable\");","handlingStrategy":"type-guard","validationCode":"const local = await options.getLocalRuntime();\nconst ready = typeof local?.baseUrl === \"string\" && local.baseUrl.length > 0 && typeof local?.token === \"string\" && local.token.length > 0;\nif (!ready) throw new Error(\"Desktop runtime not connected; start the server and sign in first\");","typeGuard":"function isLocalRuntimeReady(local) {\n  return (\n    local !== null && typeof local === \"object\" &&\n    typeof local.baseUrl === \"string\" && local.baseUrl.length > 0 &&\n    typeof local.token === \"string\" && local.token.length > 0\n  );\n}","tryCatchPattern":"try {\n  await executeDesktopAutomation(assignment, options);\n} catch (err) {\n  if (err.message === \"The desktop runtime is unavailable\") {\n    await reconnectDesktopRuntime();\n  } else throw err;\n}","preventionTips":["Check runtime readiness before enqueuing/scheduling automations","Invalidate cached runtime descriptors when the server disconnects","Reconnect and refresh the token automatically on app focus","Surface runtime status in the automation scheduler UI"],"tags":["runtime","automation","server-unavailable"],"backgroundTag":"runtime-unavailable","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}