different-ai/openwork · warning · ApiError

agent_diagnostics_in_progress

agent_diagnostics_in_progress

Error message

Agent diagnostics are already in progress

What it means

This 429 error is thrown by reserveAgentDiagnosticsRun when the same actor/workspace key already has an in-flight agent diagnostics run registered on the server. The reservation set (agentDiagnosticsInFlightByServer) tracks active runs per server config; a second request with the same key is rejected rather than queued. It protects the engine from concurrent duplicate diagnostics that would waste resources or corrupt state.

Source

Thrown at apps/server/src/server.ts:214

    const oldest = agentDiagnosticsLastRun.keys().next().value;
    if (oldest) agentDiagnosticsLastRun.delete(oldest);
  }
  agentDiagnosticsLastRun.set(key, now);
}

function reserveAgentDiagnosticsRun(
  config: ServerConfig,
  actor: Actor | undefined,
  workspaceId: string,
): () => void {
  const key = agentDiagnosticsActorWorkspaceKey(actor, workspaceId);
  const inFlight = agentDiagnosticsInFlightByServer.get(config) ?? new Set<string>();
  agentDiagnosticsInFlightByServer.set(config, inFlight);
  // Preserve the existing cooldown response for ordinary repeated attempts.
  // A zero/expired cooldown still cannot bypass the in-flight reservation.
  requireAgentDiagnosticsRateLimit(config, actor, workspaceId);
  if (inFlight.has(key)) {
    throw new ApiError(429, "agent_diagnostics_in_progress", "Agent diagnostics are already in progress");
  }
  if (inFlight.size >= AGENT_DIAGNOSTICS_MAX_IN_FLIGHT_PER_SERVER) {
    throw new ApiError(429, "agent_diagnostics_busy", "Agent diagnostics are temporarily busy");
  }

  // The cooldown charge and reservation are synchronous, so no second request
  // for this actor/workspace can slip in between them.
  inFlight.add(key);
  let released = false;
  return () => {
    if (released) return;
    released = true;
    inFlight.delete(key);
  };
}

const OPENWORK_VOICE_REALTIME_TOOLS = [
  {

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Wait for the in-flight run to complete before retrying
  2. Check the current run's status via the diagnostics status endpoint instead of re-issuing
  3. Add client-side debounce/lock so only one diagnostics request is outstanding per workspace
  4. Poll with backoff rather than immediate retries on 429

Example fix

// before
await Promise.all([runDiagnostics(serverId), runDiagnostics(serverId)]);
// after
const existing = inFlightRuns.get(serverId);
if (!existing) inFlightRuns.set(serverId, runDiagnostics(serverId));
await inFlightRuns.get(serverId);
Defensive patterns

Strategy: retry

Validate before calling

// track in-flight runs client-side
if (activeRuns.has(serverKey)) throw new Error("diagnostics already running for this workspace");

Try / catch

try {
  await reserveAgentDiagnosticsRun(config);
} catch (e) {
  if (e.code === "agent_diagnostics_in_progress") {
    await waitForExistingRun(key); // poll status instead of retrying
  } else throw e;
}

Prevention

When it happens

Trigger: POSTing an agent diagnostics request for the same server+actor+workspace while a previous diagnostics run for that exact key is still active (inFlight.has(key) is true). Happens when clients retry without waiting for the first run to finish, or fire parallel identical requests.

Common situations: Double-clicking a 'Run diagnostics' button; a client retrying after a slow response; a scheduled job overlapping a manually triggered run; UI not disabling the trigger while diagnostics run.

Related errors


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