debug(bot): classify_and_route 상세 로그 추가 + 파이프라인 검증 스크립트

This commit is contained in:
2026-03-18 18:26:33 +09:00
parent 62bc257be6
commit 35b9813d44
2 changed files with 158 additions and 2 deletions

View File

@@ -384,10 +384,13 @@ async def on_message(message: discord.Message):
gemini = GeminiCaller()
history = await _get_channel_history(message.channel, limit=10)
classify_input = f"{history}## User Message\n{user_text}"
logger.info(f"[분류] 입력: {user_text[:80]}")
raw = await gemini.call("unified", classify_input, timeout=60)
logger.info(f"[분류] Gemini 출력 ({len(raw)}자): {raw[:200]}")
# JSON 파싱
parsed = _parse_unified_response(raw)
logger.info(f"[분류] 파싱 결과: {parsed}")
# 진행 메시지 삭제
if progress_msg:
@@ -397,17 +400,20 @@ async def on_message(message: discord.Message):
pass
mode = parsed.get("mode", "chat")
logger.info(f"분류 결과: mode={mode}\"{user_text[:50]}\"")
logger.info(f"[라우팅] mode={mode}\"{user_text[:50]}\"")
# ── 라우팅 ──
if mode == "nextcloud":
# NC 핸들러로 직접 라우팅
logger.info(f"[NC] tool={parsed.get('tool')} op={parsed.get('op')} params={parsed.get('params')}")
await _nc_handler.handle(parsed, message.channel)
logger.info("[NC] handle 완료")
elif mode == "chat":
# 즉시 응답
response = parsed.get("response", "")
logger.info(f"[chat] 응답 길이: {len(response)}")
if response:
if len(response) <= 2000:
await message.reply(response)
@@ -435,6 +441,7 @@ async def on_message(message: discord.Message):
elif mode == "task":
# 에이전트 모드 (파일 작업 필요)
logger.info("[task] 에이전트 호출 시작")
async with message.channel.typing():
response = await _agent_call(user_text, history, ws.path)
if response:
@@ -459,9 +466,10 @@ async def on_message(message: discord.Message):
)
)
except GeminiCallError as e:
logger.error(f"[분류] GeminiCallError: {e}")
await message.reply(f"⚠️ AI 호출 오류: {str(e)[:200]}")
except Exception as e:
logger.error(f"분류/라우팅 오류: {e}", exc_info=True)
logger.error(f"[분류/라우팅] 예외: {e}", exc_info=True)
await message.reply(f"❌ 오류: {str(e)[:200]}")
finally:
_running_tasks.pop(channel_id, None)