<function_under_test name="{{ function_name }}">
```python
{{ function_source_code }}
```
</function_under_test>

<test_file>
```python
{{ test_source }}
```
</test_file>

<functions_to_repair>
{% for fn in functions_to_repair -%}
- `{{ fn.function_name }}`: {{ fn.reason }}
{% endfor %}
</functions_to_repair>
{% if previous_repair_errors %}

<previous_repair_errors>
A previous repair attempt for these functions was tried but the rewritten tests still failed at runtime. Use these error messages to understand what went wrong and avoid the same mistakes:
{% for fn_name, error_msg in previous_repair_errors.items() -%}
- `{{ fn_name }}`: {{ error_msg }}
{% endfor %}
</previous_repair_errors>
{% endif %}
{% if coverage_context %}

<coverage_details>
{{ coverage_context }}

When rewriting flagged functions, ensure they exercise the unexecuted lines listed above. Tests that only trigger early-return or disabled code paths do not provide useful coverage.
</coverage_details>
{% endif %}

Rewrite only the functions listed above. Return the complete file.
