From 6b60131902bdec05f220c8ec1dd13c83fa7e1006 Mon Sep 17 00:00:00 2001 From: "MSI\\ModSetter" Date: Sat, 26 Jul 2025 00:23:34 -0700 Subject: [PATCH] fix: when nothing is selected for context --- .../app/agents/researcher/nodes.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/surfsense_backend/app/agents/researcher/nodes.py b/surfsense_backend/app/agents/researcher/nodes.py index 9831115da..68a81bbae 100644 --- a/surfsense_backend/app/agents/researcher/nodes.py +++ b/surfsense_backend/app/agents/researcher/nodes.py @@ -552,6 +552,19 @@ async def fetch_relevant_documents( # Only use streaming if both writer and state are provided streaming_service = state.streaming_service if state is not None else None + # Handle case when no connectors are selected + if not connectors_to_search or len(connectors_to_search) == 0: + if streaming_service and writer: + writer( + { + "yield_value": streaming_service.format_terminal_info_delta( + "📹 No data sources selected. Research will be generated using general knowledge and any user-selected documents." + ) + } + ) + print("No connectors selected for research. Returning empty document list.") + return [] # Return empty list gracefully + # Stream initial status update if streaming_service and writer: connector_names = [ @@ -1363,8 +1376,8 @@ async def process_section_with_documents( if state and state.streaming_service and writer: writer( { - "yield_value": state.streaming_service.format_error( - f'Warning: No relevant documents found for section: "{section_title}"' + "yield_value": state.streaming_service.format_terminal_info_delta( + f'📝 Writing section "{section_title}" using general knowledge (no specific sources found)' ) } )