From 0a640aee11ad9e943685936d3e123664358f170c Mon Sep 17 00:00:00 2001 From: heaven Date: Sun, 7 Jun 2026 02:47:49 +0300 Subject: [PATCH] feat(ai-bot): log the classifier's conversation window behind the body-debug flag to diagnose about_project misroutes --- apps/ai-bot/router.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/ai-bot/router.go b/apps/ai-bot/router.go index 59cc41c0..8058e5bc 100644 --- a/apps/ai-bot/router.go +++ b/apps/ai-bot/router.go @@ -118,6 +118,14 @@ func (b *Bot) classify(ctx context.Context, body, rcx string, cost *CostBreakdow if !b.cfg.RouterClassifierEnabled || b.gemini == nil { return d } + // Emit the exact conversation window handed to the classifier — its INPUT, which the + // truncated llm-exchange body log cuts off (the static prompt fills the ~4 KB cap before + // rcx). Gated by the LOG_BODIES_USERS verbose flag exactly like logLLMExchange, since rcx + // carries user content. This is the only way to tell a real misclassification apart from + // a context-starvation problem (empty/insufficient rcx) when about_project misfires. + if ri, ok := reqInfoFromContext(ctx); ok && ri.verbose { + b.log.DebugContext(ctx, "router context", "rcx", rcx) + } // 4s router sub-deadline derived from genCtx (a budget cancel still propagates). rctx, cancel := context.WithTimeout(ctx, routerStageTimeout) defer cancel()