ruvnet/ruflo · error
AttentionCoordinator not initialized. Call initialize() firs
Error message
AttentionCoordinator not initialized. Call initialize() first.
What it means
Thrown by AttentionCoordinator#ensureInitialized (v3/@claude-flow/integration/src/attention-coordinator.ts:677). Public computation/metrics methods call this guard, so using a coordinator before `await coordinator.initialize()` completes — or after a failed initialize — fails fast. The exported helper createAttentionCoordinator() initializes before returning and avoids the trap entirely.
Source
Thrown at v3/@claude-flow/integration/src/attention-coordinator.ts:677
const len = Math.min(a.length, b.length);
for (let i = 0; i < len; i++) {
sum += a[i] * b[i];
}
return sum;
}
private cosineSimilarity(a: number[], b: number[]): number {
const dot = this.dotProduct(a, b);
const normA = Math.sqrt(this.dotProduct(a, a));
const normB = Math.sqrt(this.dotProduct(b, b));
if (normA === 0 || normB === 0) return 0;
return dot / (normA * normB);
}
private ensureInitialized(): void {
if (!this.initialized) {
throw new Error('AttentionCoordinator not initialized. Call initialize() first.');
}
}
}
/**
* Create and initialize an AttentionCoordinator
*/
export async function createAttentionCoordinator(
config?: Partial<AttentionConfiguration>
): Promise<AttentionCoordinator> {
const coordinator = new AttentionCoordinator(config);
await coordinator.initialize();
return coordinator;
}
View on GitHub (pinned to fa13ee4ad6)
Solutions
- Prefer the factory: `const coord = await createAttentionCoordinator(config);` — it initializes for you.
- Or explicitly `await coordinator.initialize()` before any compute/metrics call.
- If initialize() rejected, log and re-initialize or rebuild the coordinator; do not keep calling methods on it.
- In DI setups, wire initialization into the container's async start phase.
Example fix
// before const coord = new AttentionCoordinator(cfg); const out = coord.compute(...) // throws before init completes // after const coord = await createAttentionCoordinator(cfg); const out = coord.compute(...)
Defensive patterns
Strategy: validation
Validate before calling
const coord = await createAttentionCoordinator(cfg); // factory initializes internally
Type guard
function isCoordinatorReady(c: { initialized?: boolean }): boolean {
return c.initialized === true;
} Try / catch
try {
result = coordinator.compute(input);
} catch (e) {
if (/AttentionCoordinator not initialized/.test((e as Error).message)) {
await coordinator.initialize();
result = coordinator.compute(input);
} else throw e;
} Prevention
- Always construct via createAttentionCoordinator() unless you have a reason not to.
- Await initialize() in the async bootstrap before serving compute requests.
- Wire async lifecycle into DI containers' start phase.
When it happens
Trigger: new AttentionCoordinator(cfg) followed immediately by a compute call without awaiting initialize(); concurrent initialize() still in flight; calling after initialize() threw (e.g. bad config caught earlier) without retrying.
Common situations: Missing await in async bootstrap; DI containers that construct but do not run async lifecycle hooks; tests constructing directly instead of using createAttentionCoordinator().
Related errors
- ruvLLM bridge not initialized. Call with config first.
- Training system not initialized
- Trajectory buffer not initialized
- Flash attention not initialized
- MoE attention not initialized
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/189d2d245cf85265.
Report an issue: GitHub.