⚡ Bolt: Optimize agent thread fetching with getFullThread - #649
Conversation
The agent currently fetches a thread context by executing an N+1 query: it first fetches all thread message metadata (`stub.getEmails`), then iterates over each one to fetch the full content (`stub.getEmail`). This introduces multiple sequential RPC calls and database reads. Replaced this with a single call to `getFullThread(stub, threadId)`, which handles the complete retrieval in 2 queries inside the DO instead of N+1. This improves performance when loading agent context for longer threads. Co-authored-by: schmug <38227427+schmug@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. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
agentic-inbox | 4582441 | Jul 25 2026, 05:46 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ais-hub | 4582441 | Commit Preview URL Branch Preview URL |
Jul 25 2026, 05:45 AM |
💡 What: Replaced the N+1
getEmails+getEmailloop inworkers/agent/index.tswith a single call togetFullThread. Removed the manual date sort sincegetFullThreadhandles sorting internally.🎯 Why: To significantly reduce the latency and RPC overhead when the agent loads conversation context for a long email thread.
📊 Impact: Replaces N+1 backend queries/RPC calls with exactly 2 queries when loading context for thread processing.
🔬 Measurement: Tested via the agent unit tests (
tests/agent/). The agent interactions will load context much faster for multi-email conversations.PR created automatically by Jules for task 4770454058648516496 started by @schmug