diff --git a/ai-hub/app/core/pipelines/rag_pipeline.py b/ai-hub/app/core/pipelines/rag_pipeline.py index 35e8243..db0723a 100644 --- a/ai-hub/app/core/pipelines/rag_pipeline.py +++ b/ai-hub/app/core/pipelines/rag_pipeline.py @@ -199,17 +199,18 @@ logging.info(f"[🔧] Agent calling tool (PARALLEL): {func_name} with {func_args}") - if tool_service: - # Notify UI about tool execution start - yield {"type": "tool_start", "name": func_name, "args": func_args} - - # Create an async task for each tool call - tool_tasks.append(asyncio.create_task( - tool_service.call_tool(func_name, func_args, db=db, user_id=user_id) - )) - else: - # Treat as failure immediately if no service - tool_tasks.append(asyncio.sleep(0, result={"success": False, "error": "Tool service not available"})) + if tool_service: + # Notify UI about tool execution start + yield {"type": "tool_start", "name": func_name, "args": func_args} + + # Create an async task for each tool call + tool_tasks.append(asyncio.create_task( + tool_service.call_tool(func_name, func_args, db=db, user_id=user_id) + )) + else: + # Treat as failure immediately if no service + tool_tasks.append(asyncio.sleep(0, result={"success": False, "error": "Tool service not available"})) + # 3. HEARTBEAT WAIT: Wait for all sub-agent tasks to fulfill wait_start = time.time()