different-ai/openwork · error · Error

The desktop runtime is unavailable

Error message

The desktop runtime is unavailable

What it means

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.

Solutions

  1. Ensure the local OpenWork server is running and the desktop app is connected before automations execute
  2. Reconnect/sign in to regenerate the runtime token
  3. Make getLocalRuntime() await server readiness (retry until baseUrl+token present)
  4. Skip/park scheduled assignments when runtime is unavailable instead of executing

Example fix

// before
const local = await options.getLocalRuntime();
if (!local?.baseUrl || !local?.token) throw new Error("The desktop runtime is unavailable");
// after: ensure connection before executing
let local = await options.getLocalRuntime();
if (!local?.baseUrl || !local?.token) local = await reconnectLocalRuntime();
if (!local?.baseUrl || !local?.token) throw new Error("The desktop runtime is unavailable");
Defensive patterns

Strategy: type-guard

Validate before calling

const local = await options.getLocalRuntime();
const ready = typeof local?.baseUrl === "string" && local.baseUrl.length > 0 && typeof local?.token === "string" && local.token.length > 0;
if (!ready) throw new Error("Desktop runtime not connected; start the server and sign in first");

Type guard

function isLocalRuntimeReady(local) {
  return (
    local !== null && typeof local === "object" &&
    typeof local.baseUrl === "string" && local.baseUrl.length > 0 &&
    typeof local.token === "string" && local.token.length > 0
  );
}

Try / catch

try {
  await executeDesktopAutomation(assignment, options);
} catch (err) {
  if (err.message === "The desktop runtime is unavailable") {
    await reconnectDesktopRuntime();
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: Server not started before automations run; server connection dropped but runtime cache not refreshed; token cleared after sign-out while scheduled automations still fire.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/766a0646a5ea3655. Report an issue: GitHub.

Appendix: source

Thrown at apps/desktop/electron/automation-runner.mjs:152

  const workspaces = Array.isArray(listed?.items) ? listed.items : []
  if (pinnedWorkspaceId) {
    const pinned = workspaces.find((item) => item?.id === pinnedWorkspaceId)
    if (!pinned?.id) {
      const error = new Error(`The Automation's pinned workspace is not available on this desktop`)
      Object.defineProperty(error, "code", { value: "execution_runtime_unavailable" })
      throw error
    }
    return pinned
  }
  const workspace = workspaces.find((item) => item?.id === listed?.activeId) ?? workspaces[0]
  if (!workspace?.id) throw new Error("No local workspace is available")
  return workspace
}

/** Runs the assignment as a normal visible local OpenWork thread. */
export async function executeDesktopAutomation(assignment, options) {
  const local = await options.getLocalRuntime()
  if (!local?.baseUrl || !local?.token) throw new Error("The desktop runtime is unavailable")
  const localRequest = (requestPath, request = {}) => requestJson(
    options.fetchImpl ?? fetch,
    local.baseUrl,
    local.token,
    requestPath,
    { ...request, signal: options.signal },
  )
  const listed = await localRequest("/workspaces")
  const workspace = resolveAssignmentWorkspace(listed, assignment.workspaceId ?? null)
  const workspaceId = String(workspace.id)
  const client = createWorkspaceSessionClient(local, workspaceId, options.fetchImpl ?? fetch)
  const created = await client.createThread({
    title: `Automation: ${assignment.automationName}`.slice(0, 120),
    ...(assignment.instructions ? { prompt: assignment.instructions } : {}),
    model: assignment.model,
    signal: options.signal,
  })
  const sessionId = created.id

View on GitHub (pinned to 2b7df46e8a)