Problem
The first request to /api/control/sessions, /api/sandbox and /api/models after a deploy takes 30 to 40 seconds, and /api/github/owners returns one 503. During that window Control shows "No sessions yet". Two deploys on 2026-09-07 reproduced it.
Ruled out: Vercel is on Fluid compute in iad1, Neon is in us-east-1 with suspend_timeout_seconds: 0 (compute never sleeps). No module-scope pool creation or top-level await was found in the Control routes. The likely cause is the size of the import graph: app/api/control/chat/_lib/execute.ts pulls about 25 first-party modules that fan out into the full tool, harness and model-resolver tree, plus Sentry init in instrumentation.ts.
Where
app/api/control/chat/_lib/execute.ts (import graph root)
instrumentation.ts:5 (dynamic import of the Sentry server config)
app/api/models/route.ts:227-243 (six parallel queries, no caching, on the hot path of every picker)
Fix
This is an investigation with a measured outcome, not a guessed change.
- Measure. Use Vercel's runtime logs or a Sentry transaction on the first request after a deploy and record where the time goes: function init, first DB connection, first query, Sentry init.
- Report the breakdown in this issue before changing code.
- Then fix the largest bucket. Likely candidates: lazy-import the tool registry inside the handler instead of at module scope; cache
/api/models per user for 60 seconds; warm the function with a post-deploy ping in deploy-production.yml.
Exit criteria
Out of scope
The UI loading states. Those are covered by the session list and picker issues and should land regardless.
https://claude.ai/code/session_01SQ4nS96XYRztd5w9QkubPf
Problem
The first request to
/api/control/sessions,/api/sandboxand/api/modelsafter a deploy takes 30 to 40 seconds, and/api/github/ownersreturns one 503. During that window Control shows "No sessions yet". Two deploys on 2026-09-07 reproduced it.Ruled out: Vercel is on Fluid compute in iad1, Neon is in us-east-1 with
suspend_timeout_seconds: 0(compute never sleeps). No module-scope pool creation or top-level await was found in the Control routes. The likely cause is the size of the import graph:app/api/control/chat/_lib/execute.tspulls about 25 first-party modules that fan out into the full tool, harness and model-resolver tree, plus Sentry init ininstrumentation.ts.Where
app/api/control/chat/_lib/execute.ts(import graph root)instrumentation.ts:5(dynamic import of the Sentry server config)app/api/models/route.ts:227-243(six parallel queries, no caching, on the hot path of every picker)Fix
This is an investigation with a measured outcome, not a guessed change.
/api/modelsper user for 60 seconds; warm the function with a post-deploy ping indeploy-production.yml.Exit criteria
/api/control/sessionsafter a deploy is under 5 seconds, measured the same way and posted here.Out of scope
The UI loading states. Those are covered by the session list and picker issues and should land regardless.
https://claude.ai/code/session_01SQ4nS96XYRztd5w9QkubPf