different-ai/openwork · error · Error

Agent diagnostics require a connected workspace.

Error message

Agent diagnostics require a connected workspace.

What it means

The agent-context diagnostics collector requires an authenticated client, a selected workspaceId, a selected workspace record, and that the workspace passes isAgentContextDiagnosticsWorkspaceAllowed (e.g., a connected workspace type eligible for diagnostics). Any missing precondition aborts before collectAgentContextDiagnosticObservations.

Source

Thrown at apps/app/src/react-app/shell/settings-route.tsx:2169

    cloudSession.baseUrl,
    cloudSession.isSignedIn,
    cloudSession.user?.id,
    diagnosticsClient,
    diagnosticsWorkspaceType,
    runtimeWorkspaceId,
    selectedWorkspaceEndpoint?.token,
    token,
  ]);
  const runAgentContextDiagnostics = useCallback(async () => {
    const client = selectedWorkspaceEndpoint?.client ?? openworkClient;
    const workspaceId = runtimeWorkspaceId?.trim() ?? "";
    if (
      !client
      || !workspaceId
      || !selectedWorkspace
      || !isAgentContextDiagnosticsWorkspaceAllowed(selectedWorkspace)
    ) {
      throw new Error("Agent diagnostics require a connected workspace.");
    }
    const observations = await collectAgentContextDiagnosticObservations({
      organizationConnections: orgMcpConnections.connections,
      organizationConnectionsProbe,
      workspaceType: selectedWorkspace.workspaceType,
    });
    return client.runAgentContextDiagnostics(workspaceId, observations);
  }, [
    openworkClient,
    organizationConnectionsProbe,
    orgMcpConnections.connections,
    runtimeWorkspaceId,
    selectedWorkspace,
    selectedWorkspaceEndpoint,
  ]);
  const routeOpenworkStatus = openworkClient ? "connected" : "disconnected";
  const notFoundRouteError = !loading && routeWorkspaceId && !selectedWorkspace
    ? "Workspace was not found. Select a new workspace from the sidebar."

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Select a connected workspace in Settings before opening agent diagnostics.
  2. Reconnect the OpenWork server so a client instance exists.
  3. Verify the selected workspace passes isAgentContextDiagnosticsWorkspaceAllowed (check its workspaceType); switch to an allowed workspace.

Example fix

// before
const observations = await collectAgentContextDiagnosticObservations({...});
// after
if (!client || !workspaceId || !selectedWorkspace) return null;
const observations = await collectAgentContextDiagnosticObservations({...});
Defensive patterns

Strategy: validation

Validate before calling

const ready = Boolean(client && workspaceId && selectedWorkspace && isAgentContextDiagnosticsWorkspaceAllowed(selectedWorkspace));
if (!ready) return null; // render 'select a workspace' state instead of running diagnostics

Type guard

function diagnosticsReady(ws: WorkspaceInfo | null, c: unknown, id: string | null)
  : ws is WorkspaceInfo {
  return c !== null && typeof id === "string" && ws !== null
    && isAgentContextDiagnosticsWorkspaceAllowed(ws);
}

Try / catch

try {
  await runAgentDiagnostics();
} catch (e) {
  if (e instanceof Error && e.message === "Agent diagnostics require a connected workspace.") {
    setDiagnosticsUiState("needs-workspace");
  } else throw e;
}

Prevention

When it happens

Trigger: Opening/refreshing the agent diagnostics panel while no workspace is selected, the OpenWork client is null (server disconnected), or the selected workspace's type is not allowed for agent-context diagnostics (e.g., disconnected or unsupported workspace kind).

Common situations: Landing on Settings before choosing a workspace; server dropped so `client` became null; selecting a workspace type excluded from diagnostics allow-list.

Related errors


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