From d8d62ab2c5655d520c30ef55522e3ba5ad085a86 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 13 Feb 2026 19:52:48 +0200 Subject: [PATCH] Disable Notion tools when connector not configured --- .../app/agents/new_chat/chat_deepagent.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/surfsense_backend/app/agents/new_chat/chat_deepagent.py b/surfsense_backend/app/agents/new_chat/chat_deepagent.py index d58a0fadb..619282daf 100644 --- a/surfsense_backend/app/agents/new_chat/chat_deepagent.py +++ b/surfsense_backend/app/agents/new_chat/chat_deepagent.py @@ -243,11 +243,20 @@ async def create_surfsense_deep_agent( "available_document_types": available_document_types, } + # Disable Notion action tools if no Notion connector is configured + modified_disabled_tools = list(disabled_tools) if disabled_tools else [] + has_notion_connector = ( + available_connectors is not None and "NOTION_CONNECTOR" in available_connectors + ) + if not has_notion_connector: + notion_tools = ["create_notion_page", "update_notion_page", "delete_notion_page"] + modified_disabled_tools.extend(notion_tools) + # Build tools using the async registry (includes MCP tools) tools = await build_tools_async( dependencies=dependencies, enabled_tools=enabled_tools, - disabled_tools=disabled_tools, + disabled_tools=modified_disabled_tools, additional_tools=list(additional_tools) if additional_tools else None, )