ruvnet/ruflo · error

AgentAdapter not initialized. Call initialize() first.

Error message

AgentAdapter not initialized. Call initialize() first.

What it means

Thrown by AgentAdapter#ensureInitialized() (v3/@claude-flow/integration/src/agent-adapter.ts:600). Most operational methods call this guard first, so invoking any of them before await adapter.initialize() completed (or after a failed initialize) raises this error immediately.

Source

Thrown at v3/@claude-flow/integration/src/agent-adapter.ts:600

    };

    const mappedStatus = statusMap[agenticFlowAgent.status.toLowerCase()];
    if (mappedStatus && mappedStatus !== agent.status) {
      agent.status = mappedStatus;
      this.emit('status-synced', {
        agentId: agent.id,
        from: agenticFlowAgent.status,
        to: mappedStatus,
      });
    }
  }

  /**
   * Ensure adapter is initialized
   */
  private ensureInitialized(): void {
    if (!this.initialized) {
      throw new Error('AgentAdapter not initialized. Call initialize() first.');
    }
  }

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

/**
 * Create and initialize an AgentAdapter
 */
export async function createAgentAdapter(
  config?: Partial<AgentAdapterConfig>

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Await initialize() once before any other call: `await adapter.initialize();` then use the adapter.
  2. Create the adapter through the factory/helper (e.g. createAgentAdapter) if available, which initializes for you.
  3. Guard call sites: if (!adapter.isInitialized?.()) await adapter.initialize(); or track an `initialized` boolean in your own wrapper.
  4. If initialize() itself threw, fix that error first — retrying operations on a half-initialized adapter keeps hitting this guard.

Example fix

// before
const adapter = new AgentAdapter(config);
await adapter.execute(task); // throws

// after
const adapter = new AgentAdapter(config);
await adapter.initialize();
await adapter.execute(task);
Defensive patterns

Strategy: validation

Validate before calling

const adapter = new AgentAdapter(config);
if (!adapter.isInitialized?.()) await adapter.initialize();
// then call operational methods

Type guard

function isReady(a: { isInitialized?: () => boolean }): boolean {
  return typeof a.isInitialized === 'function' && a.isInitialized();
}

Try / catch

try {
  await adapter.execute(input);
} catch (e) {
  if ((e as Error).message.includes('not initialized')) {
    await adapter.initialize();
    return adapter.execute(input); // retry once after init
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling adapter.execute/run/register (any guarded method) right after `new AgentAdapter(...)` without awaiting initialize(); calling concurrently with an initialize() that is still in flight; calling after initialize() rejected but the code continued on a rejected-promise path.

Common situations: Missing await in an async setup path (fire-and-forget initialize()); early return from a try block that skips initialization; reusing an adapter instance across requests while an earlier failure left it uninitialized.

Related errors


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