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 edits

rUv71b1504a32c0
diff --git a/v3/@claude-flow/integration/src/token-optimizer.ts b/v3/@claude-flow/integration/src/token-optimizer.ts
index a2c5954ef8..ec1bb83e81 100644
--- a/v3/@claude-flow/integration/src/token-optimizer.ts
+++ b/v3/@claude-flow/integration/src/token-optimizer.ts
@@ -219,20 +219,33 @@ export class TokenOptimizer extends EventEmitter {
* 95% hit rate = 95% fewer embedding API calls
*/
async cachedLookup<T>(key: string, generator: () => Promise<T>): Promise<T> {
- if (!this.configTuning) {
- return generator();
+ // Use local cache if configTuning not available
+ const cacheEntry = this.localCache.get(key);
+ if (cacheEntry && Date.now() - cacheEntry.timestamp < 300000) { // 5 min TTL
+ this.stats.cacheHits++;
+ this.stats.totalTokensSaved += 100;
+ return cacheEntry.data as T;
}
- const cached = await this.configTuning.cacheGet<T>(key);
- if (cached) {
- this.stats.cacheHits++;
- this.stats.totalTokensSaved += 100; // Embedding call saved
- return cached;
+ if (this.configTuning) {
+ const cached = await this.configTuning.cacheGet(key);
+ if (cached) {
+ this.stats.cacheHits++;
+ this.stats.totalTokensSaved += 100;
+ return cached as T;
+ }
}
this.stats.cacheMisses++;
const result = await generator();
- await this.configTuning.cacheSet(key, result);
+
+ // Store in local cache
+ this.localCache.set(key, { data: result, timestamp: Date.now() });
+
+ if (this.configTuning) {
+ await this.configTuning.cacheSet(key, result);
+ }
+
return result;
}