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.
fix(block): Avoid infinite loop execution on AddToListBlock self-loop (#9629)
Zamil Majdye6de8b98f7c4
diff --git a/autogpt_platform/backend/backend/blocks/basic.py b/autogpt_platform/backend/backend/blocks/basic.pyindex 21c510db0b..0208348aad 100644--- a/autogpt_platform/backend/backend/blocks/basic.py+++ b/autogpt_platform/backend/backend/blocks/basic.py@@ -468,11 +468,27 @@ class AddToListBlock(Block):@classmethoddef get_missing_links(cls, data: BlockInput, links: List["Link"]) -> set[str]:+ # If `list` self-loop present, the `entry` pin can't be static.+ list_self_loop_present = any(+ link.sink_name == "list" and link.sink_id == link.source_id+ for link in links+ )+ entry_static_output_present = any(+ link.sink_name == "entry" and link.is_static for link in links+ )+ if list_self_loop_present and entry_static_output_present:+ raise ValueError(+ "The `entry` pin can't have static output from `AgentInput` or "+ "`StoreValue` block as long as the `list` pin has a self-loop."+ "This will cause an infinite execution loop."+ )+return super().get_missing_links(data,[linkfor link in links+ # Allow execution with `list` pin self-loopif link.sink_name != "list" or link.sink_id != link.source_id],)