feat(ai-bot): log the classifier's conversation window behind the body-debug flag to diagnose about_project misroutes

This commit is contained in:
heaven 2026-06-07 02:47:49 +03:00
parent 91899f56fb
commit 0a640aee11

View file

@ -118,6 +118,14 @@ func (b *Bot) classify(ctx context.Context, body, rcx string, cost *CostBreakdow
if !b.cfg.RouterClassifierEnabled || b.gemini == nil { if !b.cfg.RouterClassifierEnabled || b.gemini == nil {
return d 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). // 4s router sub-deadline derived from genCtx (a budget cancel still propagates).
rctx, cancel := context.WithTimeout(ctx, routerStageTimeout) rctx, cancel := context.WithTimeout(ctx, routerStageTimeout)
defer cancel() defer cancel()