Build a targeted prompt for fixing failing tests.
(source_path, source_code, test_path, failures, iteration)
| 66 | return None |
| 67 | |
| 68 | def build_fix_prompt(source_path, source_code, test_path, failures, iteration): |
| 69 | """Build a targeted prompt for fixing failing tests.""" |
| 70 | failure_text = '' |
| 71 | for name, error in failures[:3]: # max 3 failures to stay in context |
| 72 | failure_text += f'\nFAILED: {name}\n{error[:300]}\n' |
| 73 | return ( |
| 74 | f'Fix {Path(source_path).name} so the failing tests pass.\n\n' |
| 75 | f'Failing tests:{failure_text}\n' |
| 76 | f'Current {Path(source_path).name}:\n```python\n{source_code}\n```\n\n' |
| 77 | f'Rewrite {Path(source_path).name} to fix ONLY the failing tests. ' |
| 78 | f'Do not break passing tests. Use write_file.' |
| 79 | ) |
| 80 | |
| 81 | def build_generate_prompt(source_path, test_path, test_code): |
| 82 | """Build prompt to write initial implementation from tests.""" |