diff --git a/.jules/bolt.md b/.jules/bolt.md index 134f394..f0d430b 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -1,3 +1,7 @@ ## 2026-04-25 - LLM API Connection Pooling **Learning:** Making repeated API calls to external LLM providers (e.g. OpenRouter, OpenAI) without HTTP Keep-Alive results in 100-200ms of unnecessary TCP/TLS handshake overhead per request. In an agentic loop, this accumulates significantly. **Action:** When initializing HTTP clients (like Axios) for repeated internal/external services, configure them with an `https.Agent` setting `keepAlive: true` to pool connections. + +## 2026-05-22 - Cache Identical Search Queries in Agentic Loops +**Learning:** Agentic loops often repeat the same expensive queries during planning phases, causing significant bottlenecks. +**Action:** Implemented in-memory caching (e.g., using a Map) for tools that repeatedly query the same context (like `SearchTool.deep`) to instantly return identical results, preventing redundant API calls and improving execution speed. diff --git a/src/tools/index.ts b/src/tools/index.ts index 6af329e..62cbfde 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -60,12 +60,22 @@ export class FileTool { } export class SearchTool { + // ⚡ Bolt Optimization: Cache identical search queries + // Agentic loops often repeat the same expensive queries during planning phases. + // Caching results in memory prevents redundant API calls and eliminates this bottleneck. + private cache = new Map>(); + constructor(private core: CoreEngine) {} async deep(query: string): Promise> { + if (this.cache.has(query)) { + this.core.log(`Cache hit for deep search: ${query}`); + return this.cache.get(query)!; + } + this.core.log(`Initiating deep search for: ${query}`); // This is where real API calls to Google/X/Reddit would go - return this.core.execute(async () => { + const result = await this.core.execute(async () => { // Simulated results for the SDK base return { query, @@ -76,5 +86,11 @@ export class SearchTool { ] }; }); + + if (result.success) { + this.cache.set(query, result); + } + + return result; } }