diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py b/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py index 1c7d73e3f8..eb3f038f3e 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py @@ -74,7 +74,7 @@ class DecompositionStep(TypedDict, total=False): class DecompositionResult(TypedDict, total=False): """Result from decompose_goal - can be instructions, questions, or error.""" - type: str # "instructions", "clarifying_questions", "error", etc. + type: str steps: list[DecompositionStep] questions: list[dict[str, Any]] error: str @@ -518,7 +518,6 @@ async def decompose_goal( """ _check_service_configured() logger.info("Calling external Agent Generator service for decompose_goal") - # Convert typed dicts to plain dicts for external service result = await decompose_goal_external( description, context, _to_dict_list(library_agents) ) @@ -544,7 +543,6 @@ async def generate_agent( """ _check_service_configured() logger.info("Calling external Agent Generator service for generate_agent") - # Convert typed dicts to plain dicts for external service result = await generate_agent_external( dict(instructions), _to_dict_list(library_agents) ) @@ -761,7 +759,6 @@ async def generate_agent_patch( """ _check_service_configured() logger.info("Calling external Agent Generator service for generate_agent_patch") - # Convert typed dicts to plain dicts for external service return await generate_agent_patch_external( update_request, current_agent, _to_dict_list(library_agents) ) diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/errors.py b/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/errors.py index 60a5aa3bc2..282d8cf9aa 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/errors.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/errors.py @@ -18,21 +18,15 @@ def _sanitize_error_details(details: str) -> str: Returns: Sanitized error details safe for user display """ - # Remove file paths (Unix-style) sanitized = re.sub( r"/[a-zA-Z0-9_./\-]+\.(py|js|ts|json|yaml|yml)", "[path]", details ) - # Remove file paths (Windows-style) sanitized = re.sub(r"[A-Z]:\\[a-zA-Z0-9_\\.\\-]+", "[path]", sanitized) - # Remove database URLs sanitized = re.sub( r"(postgres|mysql|mongodb|redis)://[^\s]+", "[database_url]", sanitized ) - # Remove URLs with credentials sanitized = re.sub(r"https?://[^:]+:[^@]+@[^\s]+", "[url]", sanitized) - # Remove line numbers from stack traces sanitized = re.sub(r", line \d+", "", sanitized) - # Remove "File" references from stack traces sanitized = re.sub(r'File "[^"]+",?', "", sanitized) return sanitized.strip() @@ -92,11 +86,8 @@ def get_user_message_for_error( else: base_message = f"Failed to {operation}. Please try again." - # Add error details if provided (sanitized and truncated) if error_details: - # Sanitize to remove sensitive information details = _sanitize_error_details(error_details) - # Truncate long error details if len(details) > 200: details = details[:200] + "..." base_message += f"\n\nTechnical details: {details}"