Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(block): Allow undefined self-loop link to `list` input pin on `AddToListBlock` (#9599)

Zamil Majdyaa6f91039c84
diff --git a/autogpt_platform/backend/backend/blocks/basic.py b/autogpt_platform/backend/backend/blocks/basic.py
index f52a53a4eb..21c510db0b 100644
--- a/autogpt_platform/backend/backend/blocks/basic.py
+++ b/autogpt_platform/backend/backend/blocks/basic.py
@@ -1,7 +1,14 @@
import enum
-from typing import Any, List
-
-from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema, BlockType
+from typing import TYPE_CHECKING, Any, List
+
+from backend.data.block import (
+ Block,
+ BlockCategory,
+ BlockInput,
+ BlockOutput,
+ BlockSchema,
+ BlockType,
+)
from backend.data.model import SchemaField
from backend.util import json
from backend.util.file import MediaFile, store_media_file
@@ -9,6 +16,9 @@ from backend.util.mock import MockObject
from backend.util.text import TextFormatter
from backend.util.type import convert
+if TYPE_CHECKING:
+ from backend.data.graph import Link
+
formatter = TextFormatter()
@@ -456,6 +466,17 @@ class AddToListBlock(Block):
description="The position to insert the new entry. If not provided, the entry will be appended to the end of the list.",
)
+ @classmethod
+ def get_missing_links(cls, data: BlockInput, links: List["Link"]) -> set[str]:
+ return super().get_missing_links(
+ data,
+ [
+ link
+ for link in links
+ if link.sink_name != "list" or link.sink_id != link.source_id
+ ],
+ )
+
class Output(BlockSchema):
updated_list: List[Any] = SchemaField(
description="The list with the new entry added."