From fabf4b8e3f4cae663c43f52d2e6a68360982f5d8 Mon Sep 17 00:00:00 2001 From: Dongge Liu Date: Wed, 18 Dec 2024 09:39:56 +1100 Subject: [PATCH] Ignore comment-only build script (#754) Sometimes LLM suggests a build script with comments-only when it wants to reuse the existing build script, e.g., ``` # Reuse the existing build.sh ``` This avoids confusing LLM to 'think' the build script works. Returning `''` will make OFG use the existing build script. --- agent/base_agent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/base_agent.py b/agent/base_agent.py index e5e64b6ed..a0a64c140 100644 --- a/agent/base_agent.py +++ b/agent/base_agent.py @@ -75,6 +75,9 @@ def _filter_code(self, raw_code_block: str) -> str: line for line in raw_code_block.splitlines() if not line.strip().startswith('```') ] + # Sometimes LLM returns a build script containing only comments. + if all(line.strip().startswith('#') for line in filtered_lines): + return '' filtered_code_block = '\n'.join(filtered_lines) return filtered_code_block