ruvnet/ruflo · error

SwarmAdapter not initialized. Call initialize() first.

Error message

SwarmAdapter not initialized. Call initialize() first.

What it means

SwarmAdapter's ensureInitialized guard: coordinated swarm operations require a completed initialize(). The throw means the adapter's topology/config was never initialized — or its initialization failed — before the first swarm call.

Source

Thrown at v3/@claude-flow/integration/src/swarm-adapter.ts:1058

    // Apply rotary encoding (simplified)
    for (let i = 0; i < dim - 1; i += 2) {
      const cos = position[i];
      const sin = position[i + 1] ?? 0;

      const x1 = embedding[i];
      const x2 = embedding[i + 1] ?? 0;

      result[i] = x1 * cos - x2 * sin;
      result[i + 1] = x1 * sin + x2 * cos;
    }

    return result;
  }

  private ensureInitialized(): void {
    if (!this.initialized) {
      throw new Error('SwarmAdapter not initialized. Call initialize() first.');
    }
  }

  private logDebug(message: string, data?: unknown): void {
    if (this.config.debug) {
      console.debug(`[SwarmAdapter] ${message}`, data || '');
    }
  }
}

// ============================================================================
// Factory Functions
// ============================================================================

/**
 * Create and initialize a SwarmAdapter
 */
export async function createSwarmAdapter(

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Use the swarm adapter's factory function (createSwarmAdapter), which constructs and initializes
  2. Otherwise make await adapter.initialize() the first statement of your bootstrap, before any swarm call
  3. Diagnose and fix any swallowed initialization error — this guard only reflects it

Example fix

// before
const swarm = new SwarmAdapter(config);
swarm.coordinate(task); // throws: initialize() not called

// after
const swarm = await createSwarmAdapter(config);
swarm.coordinate(task);
Defensive patterns

Strategy: validation

Validate before calling

// One initialized swarm instance for the app lifetime
let swarmPromise: Promise<SwarmAdapter> | null = null;
function getSwarm(): Promise<SwarmAdapter> {
  swarmPromise ??= createSwarmAdapter(config);
  return swarmPromise;
}

Try / catch

try {
  await swarm.coordinate(task);
} catch (e) {
  if (e instanceof Error && e.message.includes('SwarmAdapter not initialized')) {
    // initialize (or use the factory) and retry once — otherwise fix the swallowed init error
  }
  throw e;
}

Prevention

When it happens

Trigger: Invoking swarm operations on a new SwarmAdapter instance before await initialize() resolves, or after a failed init left this.initialized false.

Common situations: Un-awaited init promise; per-module instantiation where the used instance was never initialized; an earlier initialization error being swallowed before first use.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/3fd3511a9513e8db. Report an issue: GitHub.