From 753726dc1878152f1aae962d759709a8374a7b49 Mon Sep 17 00:00:00 2001 From: Swifty Date: Fri, 13 Feb 2026 15:52:15 +0100 Subject: [PATCH] fix(backend): disable feature request tools when Linear config is missing Conditionally register search_feature_requests and create_feature_request tools only when LINEAR_API_KEY, LINEAR_FEATURE_REQUEST_PROJECT_ID, and LINEAR_FEATURE_REQUEST_TEAM_ID are all configured. This prevents the LLM from calling tools that will fail at runtime and avoids confusing error messages for users. Co-Authored-By: Claude Opus 4.6 --- .../api/features/chat/tools/__init__.py | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/__init__.py b/autogpt_platform/backend/backend/api/features/chat/tools/__init__.py index 350776081a..d82937c8d9 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/__init__.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/__init__.py @@ -12,7 +12,6 @@ from .base import BaseTool from .create_agent import CreateAgentTool from .customize_agent import CustomizeAgentTool from .edit_agent import EditAgentTool -from .feature_requests import CreateFeatureRequestTool, SearchFeatureRequestsTool from .find_agent import FindAgentTool from .find_block import FindBlockTool from .find_library_agent import FindLibraryAgentTool @@ -46,9 +45,6 @@ TOOL_REGISTRY: dict[str, BaseTool] = { "view_agent_output": AgentOutputTool(), "search_docs": SearchDocsTool(), "get_doc_page": GetDocPageTool(), - # Feature request tools - "search_feature_requests": SearchFeatureRequestsTool(), - "create_feature_request": CreateFeatureRequestTool(), # Workspace tools for CoPilot file operations "list_workspace_files": ListWorkspaceFilesTool(), "read_workspace_file": ReadWorkspaceFileTool(), @@ -56,6 +52,38 @@ TOOL_REGISTRY: dict[str, BaseTool] = { "delete_workspace_file": DeleteWorkspaceFileTool(), } + +def _register_feature_request_tools() -> None: + """Register feature request tools only if Linear configuration is available.""" + from backend.util.settings import Settings + + try: + secrets = Settings().secrets + except Exception: + logger.warning("Feature request tools disabled: failed to load settings") + return + + if not ( + secrets.linear_api_key + and secrets.linear_feature_request_project_id + and secrets.linear_feature_request_team_id + ): + logger.info( + "Feature request tools disabled: LINEAR_API_KEY, " + "LINEAR_FEATURE_REQUEST_PROJECT_ID, or " + "LINEAR_FEATURE_REQUEST_TEAM_ID is not configured" + ) + return + + from .feature_requests import CreateFeatureRequestTool, SearchFeatureRequestsTool + + TOOL_REGISTRY["search_feature_requests"] = SearchFeatureRequestsTool() + TOOL_REGISTRY["create_feature_request"] = CreateFeatureRequestTool() + logger.info("Feature request tools enabled") + + +_register_feature_request_tools() + # Export individual tool instances for backwards compatibility find_agent_tool = TOOL_REGISTRY["find_agent"] run_agent_tool = TOOL_REGISTRY["run_agent"]