Skip to content

⚡ Bolt: Hoist system prompt and implement context caching#62

Open
SuvenSeo wants to merge 1 commit into
masterfrom
bolt-perf-optimization-hoist-cache-5932176287526278297
Open

⚡ Bolt: Hoist system prompt and implement context caching#62
SuvenSeo wants to merge 1 commit into
masterfrom
bolt-perf-optimization-hoist-cache-5932176287526278297

Conversation

@SuvenSeo

@SuvenSeo SuvenSeo commented Jun 7, 2026

Copy link
Copy Markdown
Owner

💡 What:

  1. Hoisted the getFullPrompt call outside the tool execution loop in frontend/src/lib/handlers/messageHandler.js (Telegram handler).
  2. Implemented TTL-based in-memory caching for working_memory (1 min) and semantic knowledge reranking results (5 min) in frontend/src/lib/services/context.js.
  3. Removed redundant episodic_memory database fetch and ~60 lines of dead code/constants from context.js.

🎯 Why:
The agent was rebuilding the entire system prompt and re-fetching/re-ranking knowledge and memory in every single tool iteration. For a typical multi-turn interaction with 3-5 tool calls, this resulted in 10+ redundant database queries and 3-5 expensive LLM reranking calls, significantly slowing down the response.

📊 Impact:
Reduces database queries by ~9 and expensive LLM calls by ~4 for a typical 5-iteration tool loop. Measurably improves response latency for complex agentic tasks.

🔬 Measurement:
Verify by checking the tool_call_started and tool_call_completed events in the audit log; the time between iterations should be significantly lower as context generation is skipped. Run npm test to ensure core functionality remains intact.


PR created automatically by Jules for task 5932176287526278297 started by @SuvenSeo

Hoisted getFullPrompt outside the tool execution loop in the Telegram message handler and implemented TTL-based caching for database/LLM results in context.js.

- Moved getFullPrompt outside the while loop in messageHandler.js.
- Added 1-minute caching for working_memory.
- Added 5-minute caching for semantic knowledge reranking results.
- Removed redundant episodic_memory fetch and dead code/constants in context.js.
- Ensured 'now' is correctly defined in buildContext.
- Avoided in-place mutation of keywords in fetchRelevantKnowledge.

Co-authored-by: SuvenSeo <263689617+SuvenSeo@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
seo-os-agent Ready Ready Preview, Comment Jun 7, 2026 8:13pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant