From c4ec780ad60f5f04ef1a3c48ca62d860c54cff7f Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 07:12:55 +0000 Subject: [PATCH] fix(backend): resolve circular import for block exclusion constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move EXCLUDED_BLOCK_TYPES and EXCLUDED_BLOCK_IDS to backend/data/block.py to break the circular import chain: embeddings.py → content_handlers.py → find_block.py → hybrid_search.py → embeddings.py The constants now live alongside the BlockType enum they reference, and all consumers import from the single source of truth. Co-authored-by: Nicholas Tindle --- .../api/features/chat/tools/find_block.py | 20 +------------------ .../api/features/chat/tools/run_block.py | 6 +----- .../api/features/store/content_handlers.py | 5 +---- .../backend/backend/data/block.py | 19 ++++++++++++++++++ 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/find_block.py b/autogpt_platform/backend/backend/api/features/chat/tools/find_block.py index 1c59f5aa2d..e2dc1f1fd8 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/find_block.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/find_block.py @@ -13,28 +13,10 @@ from backend.api.features.chat.tools.models import ( NoResultsResponse, ) from backend.api.features.store.hybrid_search import unified_hybrid_search -from backend.data.block import BlockType, get_block +from backend.data.block import EXCLUDED_BLOCK_IDS, EXCLUDED_BLOCK_TYPES, get_block logger = logging.getLogger(__name__) -# Blocks excluded from CoPilot standalone execution -# NOTE: This does NOT affect the Builder UI which uses load_all_blocks() directly -EXCLUDED_BLOCK_TYPES = { - BlockType.INPUT, # Graph interface definition - data enters via chat, not graph inputs - BlockType.OUTPUT, # Graph interface definition - data exits via chat, not graph outputs - BlockType.WEBHOOK, # Wait for external events - would hang forever in CoPilot - BlockType.WEBHOOK_MANUAL, # Same as WEBHOOK - BlockType.NOTE, # Visual annotation only - no runtime behavior - BlockType.HUMAN_IN_THE_LOOP, # Pauses for human approval - CoPilot IS human-in-the-loop - BlockType.AGENT, # AgentExecutorBlock requires execution_context - use run_agent tool -} - -# Blocks that have STANDARD/other types but still require graph context -EXCLUDED_BLOCK_IDS = { - # SmartDecisionMakerBlock - dynamically discovers downstream blocks via graph topology - "3b191d9f-356f-482d-8238-ba04b6d18381", -} - class FindBlockTool(BaseTool): """Tool for searching available blocks.""" diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/run_block.py b/autogpt_platform/backend/backend/api/features/chat/tools/run_block.py index 5685664db9..1414185ae8 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/run_block.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/run_block.py @@ -8,11 +8,7 @@ from typing import Any from pydantic_core import PydanticUndefined from backend.api.features.chat.model import ChatSession -from backend.api.features.chat.tools.find_block import ( - EXCLUDED_BLOCK_IDS, - EXCLUDED_BLOCK_TYPES, -) -from backend.data.block import get_block +from backend.data.block import EXCLUDED_BLOCK_IDS, EXCLUDED_BLOCK_TYPES, get_block from backend.data.execution import ExecutionContext from backend.data.model import CredentialsMetaInput from backend.data.workspace import get_or_create_workspace diff --git a/autogpt_platform/backend/backend/api/features/store/content_handlers.py b/autogpt_platform/backend/backend/api/features/store/content_handlers.py index 97ddf6b0a8..eda1babeb7 100644 --- a/autogpt_platform/backend/backend/api/features/store/content_handlers.py +++ b/autogpt_platform/backend/backend/api/features/store/content_handlers.py @@ -13,10 +13,7 @@ from typing import Any from prisma.enums import ContentType -from backend.api.features.chat.tools.find_block import ( - EXCLUDED_BLOCK_IDS, - EXCLUDED_BLOCK_TYPES, -) +from backend.data.block import EXCLUDED_BLOCK_IDS, EXCLUDED_BLOCK_TYPES from backend.data.db import query_raw_with_schema logger = logging.getLogger(__name__) diff --git a/autogpt_platform/backend/backend/data/block.py b/autogpt_platform/backend/backend/data/block.py index eb9360b037..647603a567 100644 --- a/autogpt_platform/backend/backend/data/block.py +++ b/autogpt_platform/backend/backend/data/block.py @@ -76,6 +76,25 @@ class BlockType(Enum): HUMAN_IN_THE_LOOP = "Human In The Loop" +# Blocks excluded from CoPilot standalone execution +# NOTE: This does NOT affect the Builder UI which uses load_all_blocks() directly +EXCLUDED_BLOCK_TYPES = { + BlockType.INPUT, # Graph interface definition - data enters via chat, not graph inputs + BlockType.OUTPUT, # Graph interface definition - data exits via chat, not graph outputs + BlockType.WEBHOOK, # Wait for external events - would hang forever in CoPilot + BlockType.WEBHOOK_MANUAL, # Same as WEBHOOK + BlockType.NOTE, # Visual annotation only - no runtime behavior + BlockType.HUMAN_IN_THE_LOOP, # Pauses for human approval - CoPilot IS human-in-the-loop + BlockType.AGENT, # AgentExecutorBlock requires execution_context - use run_agent tool +} + +# Blocks that have STANDARD/other types but still require graph context +EXCLUDED_BLOCK_IDS = { + # SmartDecisionMakerBlock - dynamically discovers downstream blocks via graph topology + "3b191d9f-356f-482d-8238-ba04b6d18381", +} + + class BlockCategory(Enum): AI = "Block that leverages AI to perform a task." SOCIAL = "Block that interacts with social media platforms."