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.

refactor: enrich description with context before calling Agent Generator (#11932)

Zamil Majdy2dd341c3696f
diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/service.py b/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/service.py
index c6242b0ba9..c9c960d1ae 100644
--- a/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/service.py
+++ b/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/service.py
@@ -139,11 +139,10 @@ async def decompose_goal_external(
"""
client = _get_client()
- # Build the request payload
- payload: dict[str, Any] = {"description": description}
if context:
- # The external service uses user_instruction for additional context
- payload["user_instruction"] = context
+ description = f"{description}\n\nAdditional context from user:\n{context}"
+
+ payload: dict[str, Any] = {"description": description}
if library_agents:
payload["library_agents"] = library_agents
diff --git a/autogpt_platform/backend/test/agent_generator/test_service.py b/autogpt_platform/backend/test/agent_generator/test_service.py
index d62dca1729..cc37c428c0 100644
--- a/autogpt_platform/backend/test/agent_generator/test_service.py
+++ b/autogpt_platform/backend/test/agent_generator/test_service.py
@@ -102,7 +102,7 @@ class TestDecomposeGoalExternal:
@pytest.mark.asyncio
async def test_decompose_goal_with_context(self):
- """Test decomposition with additional context."""
+ """Test decomposition with additional context enriched into description."""
mock_response = MagicMock()
mock_response.json.return_value = {
"success": True,
@@ -119,9 +119,12 @@ class TestDecomposeGoalExternal:
"Build a chatbot", context="Use Python"
)
+ expected_description = (
+ "Build a chatbot\n\nAdditional context from user:\nUse Python"
+ )
mock_client.post.assert_called_once_with(
"/api/decompose-description",
- json={"description": "Build a chatbot", "user_instruction": "Use Python"},
+ json={"description": expected_description},
)
@pytest.mark.asyncio