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
This commit is contained in:
Vincent Koc
2026-06-03 03:02:47 -07:00
committed by GitHub
parent a7c8b2a46a
commit c68938c19e

View File

@@ -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,