From b50aea3f6915fb39ee865f4159eb4bc704d92fa3 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Thu, 16 Apr 2026 09:04:01 +0900 Subject: [PATCH] =?UTF-8?q?feat(nanoclaude):=20document.ask=2010=EC=B4=88?= =?UTF-8?q?=20=ED=9B=84=20"=EC=9E=90=EB=A3=8C=EB=A5=BC=20=EB=B6=84?= =?UTF-8?q?=EC=84=9D=ED=95=98=EA=B3=A0=20=EC=9E=88=EC=8A=B5=EB=8B=88?= =?UTF-8?q?=EB=8B=A4..."=20=EC=95=88=EB=82=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- nanoclaude/services/worker.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/nanoclaude/services/worker.py b/nanoclaude/services/worker.py index 1f1fcb0..8c02416 100644 --- a/nanoclaude/services/worker.py +++ b/nanoclaude/services/worker.py @@ -368,7 +368,7 @@ async def run(job: Job) -> None: notice = "서고를 확인하는 중입니다..." await send_to_synology(notice, raw=True) - # 일반 도구 실행 (document.ask는 긴 timeout) + # 일반 도구 실행 (document.ask는 긴 timeout + 중간 안내) timeout = DOCUMENT_ASK_TIMEOUT if (tool_name == "document" and operation == "ask") else TOOL_TIMEOUT doc_start = time() if tool_name == "document": @@ -377,10 +377,28 @@ async def run(job: Job) -> None: any(k in job.message.lower() for k in ["산업안전", "위험성평가", "asme", "법령"]), any(s in job.message.lower() for s in ["목록", "리스트", "제목만"]), params.get("query", "")[:50]) - try: - result = await asyncio.wait_for(execute_tool(tool_name, operation, params), timeout=timeout) - except asyncio.TimeoutError: - result = {"ok": False, "tool": tool_name, "operation": operation, "data": [], "summary": "", "error": "⚠️ 서비스 응답 시간이 초과되었습니다."} + + # document.ask는 Gemma 분석으로 오래 걸림 → 10초 후 중간 안내 + if tool_name == "document" and operation == "ask" and job.callback == "synology": + tool_task = asyncio.create_task( + asyncio.wait_for(execute_tool(tool_name, operation, params), timeout=timeout) + ) + analyze_notice_sent = False + while not tool_task.done(): + await asyncio.sleep(2) + if not tool_task.done() and not analyze_notice_sent and (time() - doc_start) >= 10: + await send_to_synology("자료를 분석하고 있습니다...", raw=True) + analyze_notice_sent = True + try: + result = tool_task.result() + except asyncio.TimeoutError: + result = {"ok": False, "tool": tool_name, "operation": operation, "data": [], "summary": "", "error": "⚠️ 서비스 응답 시간이 초과되었습니다."} + else: + try: + result = await asyncio.wait_for(execute_tool(tool_name, operation, params), timeout=timeout) + except asyncio.TimeoutError: + result = {"ok": False, "tool": tool_name, "operation": operation, "data": [], "summary": "", "error": "⚠️ 서비스 응답 시간이 초과되었습니다."} + if tool_name == "document": logger.info("Job %s document.%s ok=%s elapsed=%.1fs", job.id, operation, result.get("ok"), time() - doc_start)