From 60c538b61286629d97f516d64ec63063f0d9ffe7 Mon Sep 17 00:00:00 2001 From: Aadesh Kheria Date: Mon, 27 Apr 2026 18:41:53 -0700 Subject: [PATCH] Add context to system prompt in AI query route This update includes a comment explaining the rationale behind appending the verified QA corpus to the system prompt for each request --- apps/backend/src/app/api/latest/ai/query/[mode]/route.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/backend/src/app/api/latest/ai/query/[mode]/route.ts b/apps/backend/src/app/api/latest/ai/query/[mode]/route.ts index 714837e57..39bbd1997 100644 --- a/apps/backend/src/app/api/latest/ai/query/[mode]/route.ts +++ b/apps/backend/src/app/api/latest/ai/query/[mode]/route.ts @@ -63,6 +63,13 @@ export const POST = createSmartRouteHandler({ const isDocsOrSearch = systemPromptId === "docs-ask-ai" || systemPromptId === "command-center-ask-ai"; let systemPrompt = getFullSystemPrompt(systemPromptId); if (isDocsOrSearch) { + // Stuffing the entire verified QA corpus into the system prompt on every + // request is intentionally naive — it grows monotonically with each new + // QA pair and re-fetches/re-sends content that's mostly unchanged across + // requests. Once the corpus is large enough to matter we should swap to + // an embedding-based retriever (top-k by query similarity) and/or cache + // the assembled context, but for the current corpus size this is fine + // and lets the model see everything systemPrompt += await getVerifiedQaContext(); } const tools = await getTools(toolNames, { auth: fullReq.auth, targetProjectId: projectId });