Phase 28: Batch Prompt Consolidation#627
Conversation
… 28) - Created `BatchExecutor` in the scheduler to group overlapping strategic tasks (e.g. `strategic_scan`, `performance_metrics`) by company tenant within a 5-minute window. - Extended `src/llm.ts` with a global request queue. Concurrent `generate` calls within the same process are now captured within a tiny 50ms window and dispatched collectively via `generateBatched`. - Added `BatchPromptBuilder` to combine multiple task prompts into a meta-prompt and parse the resultant JSON array to individually satisfy the `LLMResponse` promises. - Added metrics `batched_calls_count` and `tokens_saved_via_batching` to Health Monitor. - Preserved complete Executor loop (tool use/persistence) as batching happens strictly at the LLM API boundary. - Updated `ROADMAP.md` and created `docs/BATCH_CONSOLIDATION.md`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Phase 28: Batch Prompt Consolidation
This PR implements an optimization to significantly reduce API token usage and redundancy during routine corporate strategic scans.
Architecture Improvements:
strategic_scan,performance_metrics,market_analysis) enqueued insrc/daemon.ts. It waits up to 5 minutes to accumulate similar requests.executor.tsprocess passing all tasks as an array (JULES_BATCH_DEF). The executor triggersexecuteTaskfor each usingPromise.allSettled.src/llm.ts) intercepts theirgeneratecalls. Ifconfig.batching.enabledis true, it queues them for 50ms, then aggregates them using theBatchPromptBuilder.Testing:
tests/integration/batch_consolidation_validation.test.ts.PR created automatically by Jules for task 14842143973365691377 started by @stancsz