From fdd6793673aee9beefd956e33e2f7fa968ca0f9d Mon Sep 17 00:00:00 2001 From: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Date: Thu, 9 Jul 2026 09:12:32 +0200 Subject: [PATCH] fix(loki): proactive review skips the deterministic fleet fast-paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit THE root cause of the empty-state review returning a bare project list: the messages route's deterministic fast paths (isListProjectsQuery, create-project, develop-all, move-forward) run BEFORE the LLM, and "review my whole fleet / all my projects" tripped the list-projects shortcut → it answered with formatProjectList (meta source:"fleet-list"), never reaching askLoki. (The model was innocent — it answers this perfectly via /api/loki.) chatOnly now bypasses every fast path, so proactive analysis reaches Loki. The warm-session + echo-fallback layers stay as defense-in-depth. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app/api/conversations/[id]/messages/route.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/api/conversations/[id]/messages/route.ts b/src/app/api/conversations/[id]/messages/route.ts index ed78b7b25..a4688a7f3 100644 --- a/src/app/api/conversations/[id]/messages/route.ts +++ b/src/app/api/conversations/[id]/messages/route.ts @@ -223,8 +223,12 @@ export async function POST( const projects = await getUserProjects(userId); const projectNames = projects.map((p) => p.name); - // Fleet fast paths — deterministic, no LLM. - if (isListProjectsQuery(text)) { + // Fleet fast paths — deterministic, no LLM. Skipped entirely for chatOnly: + // the proactive fleet-review starters ("review my fleet", "all my projects") + // are analysis requests that would otherwise be intercepted here (e.g. the + // list-projects fast path) and answered with a bare project list. chatOnly + // means "let Loki think", so bypass every deterministic shortcut. + if (!chatOnly && isListProjectsQuery(text)) { const assistant = await addMessage(conversationId, { role: "assistant", kind: "chat", @@ -234,7 +238,7 @@ export async function POST( return NextResponse.json({ message: assistant }); } - const createReq = parseCreateProjectRequest(text); + const createReq = chatOnly ? null : parseCreateProjectRequest(text); if (createReq) { let name = createReq.name; if (!name) { @@ -308,7 +312,7 @@ export async function POST( return NextResponse.json({ message: assistant }); } - if (isDevelopAllFleetRequest(text)) { + if (!chatOnly && isDevelopAllFleetRequest(text)) { const scopeKeys = selectedProjects.length > 0 ? selectedProjects : undefined; const outcome = await kickFleet(userId, { @@ -329,7 +333,7 @@ export async function POST( return NextResponse.json({ message: assistant }); } - if (isMoveForwardRequest(text)) { + if (!chatOnly && isMoveForwardRequest(text)) { if (selectedProjects.length === 1) { const assistant = await persistDispatch({ userId,