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(backend): move placeholder_values exclusively to AgentDropdownInputBlock (#12551)
Zamil Majdyf79d8f044942
diff --git a/autogpt_platform/backend/backend/blocks/io.py b/autogpt_platform/backend/backend/blocks/io.pyindex c805bd599e..53fc23b68a 100644--- a/autogpt_platform/backend/backend/blocks/io.py+++ b/autogpt_platform/backend/backend/blocks/io.py@@ -28,9 +28,9 @@ class AgentInputBlock(Block):"""This block is used to provide input to the graph.- It takes in a value, name, description, default values list and bool to limit selection to default values.+ It takes in a value, name, and description.- It Outputs the value passed as input.+ It outputs the value passed as input."""class Input(BlockSchemaInput):@@ -47,12 +47,6 @@ class AgentInputBlock(Block):default=None,advanced=True,)- placeholder_values: list = SchemaField(- description="The placeholder values to be passed as input.",- default_factory=list,- advanced=True,- hidden=True,- )advanced: bool = SchemaField(description="Whether to show the input in the advanced section, if the field is not required.",default=False,@@ -65,10 +59,7 @@ class AgentInputBlock(Block):)def generate_schema(self):- schema = copy.deepcopy(self.get_field_schema("value"))- if possible_values := self.placeholder_values:- schema["enum"] = possible_values- return schema+ return copy.deepcopy(self.get_field_schema("value"))class Output(BlockSchema):# Use BlockSchema to avoid automatic error field for interface definition@@ -86,18 +77,16 @@ class AgentInputBlock(Block):"value": "Hello, World!","name": "input_1","description": "Example test input.",- "placeholder_values": [],},{- "value": "Hello, World!",+ "value": 42,"name": "input_2",- "description": "Example test input with placeholders.",- "placeholder_values": ["Hello, World!"],+ "description": "Example numeric input.",},],"test_output": [("result", "Hello, World!"),- ("result", "Hello, World!"),+ ("result", 42),],"categories": {BlockCategory.INPUT, BlockCategory.BASIC},"block_type": BlockType.INPUT,@@ -245,13 +234,11 @@ class AgentShortTextInputBlock(AgentInputBlock):"value": "Hello","name": "short_text_1","description": "Short text example 1",- "placeholder_values": [],},{"value": "Quick test","name": "short_text_2","description": "Short text example 2",- "placeholder_values": ["Quick test", "Another option"],},],test_output=[@@ -285,13 +272,11 @@ class AgentLongTextInputBlock(AgentInputBlock):"value": "Lorem ipsum dolor sit amet...","name": "long_text_1","description": "Long text example 1",- "placeholder_values": [],},{"value": "Another multiline text input.","name": "long_text_2","description": "Long text example 2",- "placeholder_values": ["Another multiline text input."],},],test_output=[@@ -325,13 +310,11 @@ class AgentNumberInputBlock(AgentInputBlock):"value": 42,"name": "number_input_1","description": "Number example 1",- "placeholder_values": [],},{"value": 314,"name": "number_input_2","description": "Number example 2",- "placeholder_values": [314, 2718],},],test_output=[@@ -501,6 +484,12 @@ class AgentDropdownInputBlock(AgentInputBlock):title="Dropdown Options",)+ def generate_schema(self):+ schema = super().generate_schema()+ if possible_values := self.placeholder_values:+ schema["enum"] = possible_values+ return schema+class Output(AgentInputBlock.Output):result: str = SchemaField(description="Selected dropdown value.")diff --git a/autogpt_platform/backend/backend/blocks/test/test_block.py b/autogpt_platform/backend/backend/blocks/test/test_block.pyindex c7f3ca62f2..569e8b767d 100644--- a/autogpt_platform/backend/backend/blocks/test/test_block.py+++ b/autogpt_platform/backend/backend/blocks/test/test_block.py@@ -4,6 +4,8 @@ import pytestfrom backend.blocks import get_blocksfrom backend.blocks._base import Block, BlockSchemaInput+from backend.blocks.io import AgentDropdownInputBlock, AgentInputBlock+from backend.data.graph import BaseGraphfrom backend.data.model import SchemaFieldfrom backend.util.test import execute_block_test@@ -279,3 +281,66 @@ class TestAutoCredentialsFieldsValidation:assert "Duplicate auto_credentials kwarg_name 'credentials'" in str(exc_info.value)+++def test_agent_input_block_ignores_legacy_placeholder_values():+ """Verify AgentInputBlock.Input.model_construct tolerates extra placeholder_values+ for backward compatibility with existing agent JSON."""+ legacy_data = {+ "name": "url",+ "value": "",+ "description": "Enter a URL",+ "placeholder_values": ["https://example.com"],+ }+ instance = AgentInputBlock.Input.model_construct(**legacy_data)+ schema = instance.generate_schema()+ assert (+ "enum" not in schema+ ), "AgentInputBlock should not produce enum from legacy placeholder_values"+++def test_dropdown_input_block_produces_enum():+ """Verify AgentDropdownInputBlock.Input.generate_schema() produces enum."""+ options = ["Option A", "Option B"]+ instance = AgentDropdownInputBlock.Input.model_construct(+ name="choice", value=None, placeholder_values=options+ )+ schema = instance.generate_schema()+ assert schema.get("enum") == options+++def test_generate_schema_integration_legacy_placeholder_values():+ """Test the full Graph._generate_schema path with legacy placeholder_values+ on AgentInputBlock — verifies no enum leaks through the graph loading path."""+ legacy_input_default = {+ "name": "url",+ "value": "",+ "description": "Enter a URL",+ "placeholder_values": ["https://example.com"],+ }+ result = BaseGraph._generate_schema(+ (AgentInputBlock.Input, legacy_input_default),+ )+ url_props = result["properties"]["url"]+ assert (+ "enum" not in url_props+ ), "Graph schema should not contain enum from AgentInputBlock placeholder_values"+++def test_generate_schema_integration_dropdown_produces_enum():+ """Test the full Graph._generate_schema path with AgentDropdownInputBlock+ — verifies enum IS produced for dropdown blocks."""+ dropdown_input_default = {+ "name": "color",+ "value": None,+ "placeholder_values": ["Red", "Green", "Blue"],+ }+ result = BaseGraph._generate_schema(+ (AgentDropdownInputBlock.Input, dropdown_input_default),+ )+ color_props = result["properties"]["color"]+ assert color_props.get("enum") == [+ "Red",+ "Green",+ "Blue",+ ], "Graph schema should contain enum from AgentDropdownInputBlock"diff --git a/autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md b/autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.mdindex b33162e279..5014cc06c2 100644--- a/autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md+++ b/autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md@@ -67,9 +67,17 @@ These define the agent's interface — what it accepts and what it produces.**AgentInputBlock** (ID: `c0a8e994-ebf1-4a9c-a4d8-89d09c86741b`):- Defines a user-facing input field on the agent- Required `input_default` fields: `name` (str), `value` (default: null)-- Optional: `title`, `description`, `placeholder_values` (for dropdowns)+- Optional: `title`, `description`- Output: `result` — the user-provided value at runtime- Create one AgentInputBlock per distinct input the agent needs+- For dropdown/select inputs, use **AgentDropdownInputBlock** instead (see below)++**AgentDropdownInputBlock** (ID: `655d6fdf-a334-421c-b733-520549c07cd1`):+- Specialized input block that presents a dropdown/select to the user+- Required `input_default` fields: `name` (str), `placeholder_values` (list of options, must have at least one)+- Optional: `title`, `description`, `value` (default selection)+- Output: `result` — the user-selected value at runtime+- Use this instead of AgentInputBlock when the user should pick from a fixed set of options**AgentOutputBlock** (ID: `363ae599-353e-4804-937e-b2ee3cef3da4`):- Defines a user-facing output displayed after the agent runsdiff --git a/autogpt_platform/backend/backend/copilot/tools/_test_data.py b/autogpt_platform/backend/backend/copilot/tools/_test_data.pyindex 1bb8e973ca..cff4e23416 100644--- a/autogpt_platform/backend/backend/copilot/tools/_test_data.py+++ b/autogpt_platform/backend/backend/copilot/tools/_test_data.py@@ -102,7 +102,6 @@ async def setup_test_data(server):"value": "","advanced": False,"description": "Test input field",- "placeholder_values": [],},metadata={"position": {"x": 0, "y": 0}},)@@ -242,7 +241,6 @@ async def setup_llm_test_data(server):"value": "","advanced": False,"description": "Prompt for the LLM",- "placeholder_values": [],},metadata={"position": {"x": 0, "y": 0}},)@@ -396,7 +394,6 @@ async def setup_firecrawl_test_data(server):"value": "","advanced": False,"description": "URL for Firecrawl to scrape",- "placeholder_values": [],},metadata={"position": {"x": 0, "y": 0}},)diff --git a/autogpt_platform/backend/test/e2e_test_data.py b/autogpt_platform/backend/test/e2e_test_data.pyindex 500075da21..add6013893 100644--- a/autogpt_platform/backend/test/e2e_test_data.py+++ b/autogpt_platform/backend/test/e2e_test_data.py@@ -254,7 +254,6 @@ class TestDataCreator:"value": "","advanced": False,"description": None,- "placeholder_values": [],},metadata={"position": {"x": -1012, "y": 674}},)@@ -274,7 +273,6 @@ class TestDataCreator:"value": "","advanced": False,"description": None,- "placeholder_values": [],},metadata={"position": {"x": -1117, "y": 78}},)diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/docs/HEIRARCHY.md b/autogpt_platform/frontend/src/components/renderers/InputRenderer/docs/HEIRARCHY.mdindex 45b4276946..c4d01234fb 100644--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/docs/HEIRARCHY.md+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/docs/HEIRARCHY.md@@ -80,11 +80,6 @@ Root (type: object)│ └── FieldTemplate → AnyOfField│ └── String → TextWidget OR Null → nothing│- ├── placeholder_values (array of strings)- │ └── FieldTemplate → ArrayFieldTemplate- │ └── ArrayFieldItemTemplate (per item)- │ └── TextWidget- │├── advanced (boolean)│ └── FieldTemplate → CheckboxWidget│diff --git a/docs/integrations/block-integrations/basic.md b/docs/integrations/block-integrations/basic.mdindex e032690edc..60f8389de1 100644--- a/docs/integrations/block-integrations/basic.md+++ b/docs/integrations/block-integrations/basic.md@@ -182,9 +182,9 @@ This is ideal when you want to constrain user input to a predefined set of choic| value | Text selected from a dropdown. | str | No || title | The title of the input. | str | No || description | The description of the input. | str | No |-| placeholder_values | Possible values for the dropdown. | List[Any] | No || advanced | Whether to show the input in the advanced section, if the field is not required. | bool | No || secret | Whether the input should be treated as a secret. | bool | No |+| placeholder_values | Possible values for the dropdown. | List[Any] | No |### Outputs@@ -293,7 +293,7 @@ A block that accepts and processes user input values within a workflow, supporti### How it works<!-- MANUAL: how_it_works -->-It accepts a value from the user, along with metadata such as name, description, and optional placeholder values. The block then outputs the provided value.+It accepts a value from the user, along with metadata such as name and description. The block then outputs the provided value.<!-- END MANUAL -->### Inputs