From facfcd75aa96564c4fe2cc29a0b7d2a160a88312 Mon Sep 17 00:00:00 2001 From: Val-sss <154882199@qq.com> Date: Fri, 8 May 2026 12:33:17 +0800 Subject: [PATCH] fix: inject raw test failure tail into prompt (no truncation logic) Replace FAILURES-section extraction (which could produce empty output) with simple tail-2000 of initial_test_failure. Applied to all three injection sites (_generate_modified, _try_hashline, _run_whole_file). Co-Authored-By: Claude Opus 4.6 (1M context) --- kaiwu/experts/generator.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/kaiwu/experts/generator.py b/kaiwu/experts/generator.py index c00c0a6..b813567 100644 --- a/kaiwu/experts/generator.py +++ b/kaiwu/experts/generator.py @@ -434,17 +434,10 @@ class GeneratorExpert: lines.append(f"- {name}: {snippet[:100]}" if snippet else f"- {name}") prompt += "\n\n" + "\n".join(lines) - # 透传pre_test的FAILURES原始输出(首次和retry都加) - test_output = initial_failure or "" - if test_output: - if "FAILURES" in test_output: - test_failure_info = test_output[test_output.index("FAILURES"):] - elif "FAILED" in test_output: - test_failure_info = test_output[-500:] - else: - test_failure_info = "" - if test_failure_info: - prompt += f"\n\n## 测试失败详情\n{test_failure_info[:1500]}" + # 透传pre_test的失败原始输出(首次和retry都加) + test_failure = getattr(ctx, 'initial_test_failure', '') or '' + if test_failure: + prompt += f"\n\n## 当前测试失败详情\n{test_failure[-2000:]}\n" # Inject retry_hint: 只传一句话总结,不传完整历史 if ctx.retry_hint: @@ -562,8 +555,8 @@ class GeneratorExpert: # 注入初始测试失败信息 initial_failure = getattr(ctx, 'initial_test_failure', '') - if initial_failure and ctx.retry_count == 0: - prompt += f"\n\n## 当前测试失败\n{initial_failure[:500]}" + if initial_failure: + prompt += f"\n\n## 当前测试失败详情\n{initial_failure[-2000:]}\n" if ctx.retry_hint: prompt += f"\n\n## 重试提示\n{ctx.retry_hint}"