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/copilot): skip AI blocks without model property in fix_ai_model_parameter (#12688)
An Vy Le43c81910ae9f
diff --git a/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py b/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.pyindex 50d0e1925a..adebd89bf1 100644--- a/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py+++ b/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py@@ -890,6 +890,12 @@ class AgentFixer:)if is_ai_block:+ # Skip AI blocks that don't expose a "model" input property+ # (some AI-category blocks have no model selector at all).+ input_properties = block.get("inputSchema", {}).get("properties", {})+ if "model" not in input_properties:+ continue+node_id = node.get("id")input_default = node.get("input_default", {})current_model = input_default.get("model")@@ -898,9 +904,7 @@ class AgentFixer:# Blocks with a block-specific enum on the model field (e.g.# PerplexityBlock) use their own enum values; others use the# generic set.- model_schema = (- block.get("inputSchema", {}).get("properties", {}).get("model", {})- )+ model_schema = input_properties.get("model", {})block_model_enum = model_schema.get("enum")if block_model_enum:diff --git a/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer_test.py b/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer_test.pyindex 07d71a941c..2319ad6760 100644--- a/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer_test.py+++ b/autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer_test.py@@ -580,6 +580,29 @@ class TestFixAiModelParameter:assert result["nodes"][0]["input_default"]["model"] == "perplexity/sonar"+ def test_ai_block_without_model_property_is_skipped(self):+ """AI-category blocks that have no 'model' input property should not+ have a model injected — they simply don't expose a model selector."""+ fixer = AgentFixer()+ block_id = generate_uuid()+ node = _make_node(node_id="n1", block_id=block_id, input_default={})+ agent = _make_agent(nodes=[node])++ blocks = [+ {+ "id": block_id,+ "name": "SomeAIBlock",+ "categories": [{"category": "AI"}],+ "inputSchema": {+ "properties": {"prompt": {"type": "string"}},+ },+ }+ ]++ result = fixer.fix_ai_model_parameter(agent, blocks)++ assert "model" not in result["nodes"][0]["input_default"]+class TestFixAgentExecutorBlocks:"""Tests for fix_agent_executor_blocks."""