Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

checkpoint: File edit:

rUv2a0089c24745
diff --git a/v3/@claude-flow/swarm/src/federation-hub.ts b/v3/@claude-flow/swarm/src/federation-hub.ts
index 47066ce86d..eda7742807 100644
--- a/v3/@claude-flow/swarm/src/federation-hub.ts
+++ b/v3/@claude-flow/swarm/src/federation-hub.ts
@@ -332,16 +332,21 @@ export class FederationHub extends EventEmitter {
clearInterval(this.cleanupInterval);
}
- // Terminate all ephemeral agents
- for (const agent of this.ephemeralAgents.values()) {
- if (agent.status === 'active' || agent.status === 'spawning') {
- await this.terminateAgent(agent.id);
- }
- }
+ // Terminate all active ephemeral agents using index - O(k) where k = active + spawning
+ const activeIds = this.getAgentIdsByStatus('active');
+ const spawningIds = this.getAgentIdsByStatus('spawning');
+ const toTerminate = [...activeIds, ...spawningIds];
+ await Promise.all(toTerminate.map(id => this.terminateAgent(id)));
+
+ // Clear all data structures and indexes
this.swarms.clear();
this.ephemeralAgents.clear();
this.proposals.clear();
+ this.agentsBySwarm.clear();
+ for (const status of this.agentsByStatus.values()) {
+ status.clear();
+ }
}
// ==========================================================================