Skip to content

perf: optimize bundle and parallelize sequential awaits - #161

Merged
sidneyswift merged 3 commits into
testfrom
feat/performance-optimization
Jan 27, 2026
Merged

perf: optimize bundle and parallelize sequential awaits#161
sidneyswift merged 3 commits into
testfrom
feat/performance-optimization

Conversation

@sidneyswift

Copy link
Copy Markdown
Contributor

Summary

  • Add optimizePackageImports for date-fns, @ai-sdk packages in next.config
  • Parallelize MCP tools and Composio tools fetching in setupToolsForRequest with Promise.all
  • Parallelize Trigger.dev schedule deletion and DB deletion in deleteTask

Impact

  • Improved API response times from parallelized independent operations
  • Faster task deletion (Trigger.dev and DB deletions run concurrently)
  • Faster chat setup (MCP and Composio tools fetched concurrently)

Test plan

  • Verify chat endpoints work correctly
  • Verify task CRUD operations work correctly
  • Verify connectors still work as expected

🤖 Generated with Claude Code

- Add optimizePackageImports for date-fns, @ai-sdk packages
- Parallelize MCP tools and Composio tools fetching with Promise.all
- Parallelize Trigger.dev schedule deletion and DB deletion in deleteTask
These optimizations improve API response times by parallelizing
independent operations.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel

vercelBot commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

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

ProjectDeploymentReviewUpdated (UTC)
recoup-apiReadyReadyPreviewJan 27, 2026 10:29pm

@coderabbitai

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actionsBot commented Jan 27, 2026

Copy link
Copy Markdown

Braintrust eval report

Catalog Opportunity Analysis Evaluation (HEAD-1769552915)

ScoreAverageImprovementsRegressions
Catalog_availability4.7% (+0pp)1 🟢1 🔴
Llm_calls0 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration41.52s (+2.57s)3 🟢2 🔴

Catalog Songs Count Evaluation (HEAD-1769552915)

ScoreAverageImprovementsRegressions
AnswerCorrectness19.4% (0pp)1 🟢2 🔴
Factuality33.3% (-33pp)-1 🔴
Llm_calls4 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Completion_accepted_prediction_tokens0tok (+0tok)--
Completion_rejected_prediction_tokens0tok (+0tok)--
Completion_audio_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration13.76s (+0.71s)1 🟢2 🔴

First Week Album Sales Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
Factuality60% (+5pp)1 🟢1 🔴
Llm_calls1 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Completion_accepted_prediction_tokens0tok (+0tok)--
Completion_rejected_prediction_tokens0tok (+0tok)--
Completion_audio_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration17.25s (+3.21s)-4 🔴

Memory & Storage Tools Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
Tools_called0% (+0pp)--
Llm_calls0 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration13.18s (-6.33s)1 🟢-

Monthly Listeners Tracking Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
AnswerSimilarity76.9% (-3pp)-5 🔴
Llm_calls2 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration12.17s (+1.51s)1 🟢4 🔴

Search Web Tool Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
AnswerCorrectness29.8% (+3pp)7 🟢4 🔴
Llm_calls3 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Completion_accepted_prediction_tokens0tok (+0tok)--
Completion_rejected_prediction_tokens0tok (+0tok)--
Completion_audio_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration26.7s (+2.16s)5 🟢6 🔴

Social Scraping Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
Tools_called0% (+0pp)--
Llm_calls0 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration21.57s (-2.2s)3 🟢3 🔴

Spotify Followers Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
AnswerCorrectness20.6% (+0pp)4 🟢1 🔴
Llm_calls3 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Completion_accepted_prediction_tokens0tok (+0tok)--
Completion_rejected_prediction_tokens0tok (+0tok)--
Completion_audio_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration14.83s (-0.07s)3 🟢2 🔴

Spotify Tools Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
Tools_called0% (+0pp)--
Llm_calls0 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration25.14s (-11.93s)1 🟢1 🔴

TikTok Analytics Questions Evaluation (HEAD-1769552914)

ScoreAverageImprovementsRegressions
Question_answered5% (-5pp)-1 🔴
Llm_calls0 (+0)--
Tool_calls0 (+0)--
Errors0 (+0)--
Llm_errors0 (+0)--
Tool_errors0 (+0)--
Prompt_tokens0tok (+0tok)--
Prompt_cached_tokens0tok (+0tok)--
Prompt_cache_creation_tokens0tok (+0tok)--
Completion_tokens0tok (+0tok)--
Completion_reasoning_tokens0tok (+0tok)--
Total_tokens0tok (+0tok)--
Duration15.75s (-1.86s)2 🟢-

@sweetmantechsweetmantech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing unit tests for TDD (red-green-refactor)

  • API changes must always include unit tests to follow TDD.

- Add comprehensive tests for deleteTask function including:
- Basic functionality (fetch, delete from DB, delete from Trigger.dev)
- Error handling (task not found, propagated errors)
- Handling tasks without trigger_schedule_id
- Parallel execution verification
- Add parallel execution tests for setupToolsForRequest:
- Verify MCP and Composio tools are fetched concurrently
- Verify both operations are called when authToken is provided
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sidneyswift
sidneyswift merged commit 5c8996c into testJan 27, 2026
5 checks passed
sidneyswift added a commit that referenced this pull request Jan 27, 2026
* fix: handle duplicate room creation race condition (#165)
* fix: handle duplicate room creation race condition
Catch 23505 unique constraint error when frontend creates room before
backend's selectRoom sees it. Skip notification if room already exists.
* fix: keep Promise.all, just wrap in try/catch
Simpler fix - keep parallel execution, only catch the 23505 error.
* fix: handle duplicate room in createNewRoom.ts
This is the actual fix - createNewRoom is called during setupConversation
at request START, which is where the 500 error occurs.
* fix: revert try/catch bandaid - no longer needed
Frontend no longer creates rooms, so no race condition.
Backend is single source of truth for room creation.
* fix: use upsert instead of insert for room creation
- Changed insertRoom to use upsert with ignoreDuplicates: true
- Reverted try/catch in createNewRoom.ts and handleChatCompletion.ts
- Cleaner solution: duplicates are silently ignored at the DB level
* fix: use upsert instead of insert for rooms
One-line fix: change insert to upsert in insertRoom.ts.
Removes try/catch workarounds since upsert handles duplicates.
* refactor: rename insertRoom to upsertRoom to match method
Renames the function and file from insertRoom to upsertRoom to align
with the actual Supabase method being called (.upsert()).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: add unit tests for upsertRoom function
Adds comprehensive unit tests covering:
- Basic upsert operation
- Null artist_id handling
- Null topic handling
- Error handling on upsert failure
- Upsert behavior (update on conflict)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* perf: optimize bundle and parallelize sequential awaits (#161)
* perf: optimize bundle and parallelize sequential awaits
- Add optimizePackageImports for date-fns, @ai-sdk packages
- Parallelize MCP tools and Composio tools fetching with Promise.all
- Parallelize Trigger.dev schedule deletion and DB deletion in deleteTask
These optimizations improve API response times by parallelizing
independent operations.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: add unit tests for parallel execution optimizations
- Add comprehensive tests for deleteTask function including:
- Basic functionality (fetch, delete from DB, delete from Trigger.dev)
- Error handling (task not found, propagated errors)
- Handling tasks without trigger_schedule_id
- Parallel execution verification
- Add parallel execution tests for setupToolsForRequest:
- Verify MCP and Composio tools are fetched concurrently
- Verify both operations are called when authToken is provided
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for freeto 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.

2 participants

@sidneyswift@sweetmantech