From c68938c19e4b7a1b5ebe65e21ec4893e62b5f4e3 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 3 Jun 2026 03:02:47 -0700 Subject: [PATCH] perf(gateway): overlap chat catalog startup Start optional model catalog loading earlier during chat history/startup hydration so catalog discovery overlaps history projection without changing the metadata contract. The response still awaits catalog-backed session/default/agents metadata before replying. Verification: - git diff --check - autoreview local caught and rejected the short-timeout variant; fixed to overlap-only - autoreview commit clean - Testbox tbx_01kt6edf5d328vqr43epy0cs0b targeted gateway/UI shards passed - Testbox tbx_01kt6eh4fk409g4ar1kpa0edhz check:changed lanes core, coreTests passed --- src/gateway/server-methods/chat.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gateway/server-methods/chat.ts b/src/gateway/server-methods/chat.ts index 52144eb6aec..b9e4f017c24 100644 --- a/src/gateway/server-methods/chat.ts +++ b/src/gateway/server-methods/chat.ts @@ -2540,6 +2540,14 @@ async function handleChatHistoryRequest({ respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, selectedAgent.error)); return; } + const modelCatalogPromise = measureDiagnosticsTimelineSpan( + `gateway.${method}.model_catalog`, + () => loadOptionalServerMethodModelCatalog(context, method), + { + config: cfg, + phase: method, + }, + ); const sessionId = entry?.sessionId; const sessionAgentId = resolveSessionAgentId({ sessionKey, @@ -2620,14 +2628,7 @@ async function handleChatHistoryRequest({ `chat.history omitted oversized payloads placeholders=${placeholderCount} total=${chatHistoryPlaceholderEmitCount}`, ); } - const modelCatalog = await measureDiagnosticsTimelineSpan( - `gateway.${method}.model_catalog`, - () => loadOptionalServerMethodModelCatalog(context, method), - { - config: cfg, - phase: method, - }, - ); + const modelCatalog = await modelCatalogPromise; const sessionInfo = buildGatewaySessionInfo({ cfg, storePath,