cold-start: lazy-load agent runner heavy dependencies#43
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR lazy-loads four heavy module dependencies (
Confidence Score: 4/5The change is safe for the tool-agent path, but the browser path has an unguarded window where a dynamic import failure leaves a run permanently stuck in the database. The src/lib/server/agent-runner/service.ts — specifically the three browser dynamic imports at lines 179–181 that fall outside the browser try/catch block. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[runAgent called] --> B{runMode === tool_agent?}
B -- Yes --> C["try { ... }"]
C --> D["await import('./tool-agent') ✅ inside try/catch"]
D --> E[runToolAgent]
E --> F[return]
C -- catch --> G[failRun]
B -- No / browser --> H["await import('openai-transport') ⚠️ outside try"]
H --> I["await import('./browser') ⚠️ outside try"]
I --> J["await import('./openai') ⚠️ outside try"]
J --> K[credential checks]
K --> L["try { ... }"]
L --> M[createBrowserSession → agent loop]
L -- catch --> N[failRun]
H -- throws --> O["❌ no failRun, run stuck in DB"]
Reviews (2): Last reviewed commit: "Lazy-load browser and tool-agent modules..." | Re-trigger Greptile |
Playwright, Browserbase, and provider SDKs are imported only when the corresponding run mode starts.
bff4529 to
2b31168
Compare

Stack Context
This stack reduces Vercel cold-start time by shrinking the shared SvelteKit server boot path and isolating heavy agent/GitHub dependencies.
Why?
The agent runner statically imported Playwright, Browserbase, and tool-agent provider SDKs at module load. Dashboard routes that only read run snapshots were paying that cost. Heavy modules now load only when the matching run mode starts.
Test plan