Trim early retry clutter
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
77e1893fde8e0daef6df15d69d6c5eeef768e686- Parents
-
024377f - Tree
e69fa9f
77e1893
77e1893fde8e0daef6df15d69d6c5eeef768e686024377f
e69fa9f| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/runtime/repair.py
|
24 | 1 |
| M |
tests/test_repair.py
|
2 | 0 |
src/loader/runtime/repair.pymodified@@ -257,7 +257,7 @@ class ResponseRepairer: | ||
| 257 | 257 | ) -> str: |
| 258 | 258 | if dod is not None and self._should_compact_empty_retry_message(dod): |
| 259 | 259 | compact_lines: list[str] = [] |
| 260 | - compact_lines.extend(self._planned_artifact_progress_lines(dod)[:2]) | |
| 260 | + compact_lines.extend(self._compact_planned_artifact_lines(dod)) | |
| 261 | 261 | compact_lines.extend(self._payload_retry_lines(dod)) |
| 262 | 262 | compact_lines.extend( |
| 263 | 263 | self._next_step_resume_lines( |
@@ -659,6 +659,29 @@ class ResponseRepairer: | ||
| 659 | 659 | lines.append("Remaining planned artifacts: " + preview) |
| 660 | 660 | return lines |
| 661 | 661 | |
| 662 | + def _compact_planned_artifact_lines(self, dod: DefinitionOfDone) -> list[str]: | |
| 663 | + lines = self._planned_artifact_progress_lines(dod) | |
| 664 | + if self._confirmed_output_file_count(dod) < 2: | |
| 665 | + return lines[:1] | |
| 666 | + return lines[:2] | |
| 667 | + | |
| 668 | + def _confirmed_output_file_count(self, dod: DefinitionOfDone) -> int: | |
| 669 | + return sum( | |
| 670 | + 1 | |
| 671 | + for target, expect_directory in collect_planned_artifact_targets( | |
| 672 | + dod, | |
| 673 | + project_root=self.context.project_root, | |
| 674 | + max_paths=12, | |
| 675 | + ) | |
| 676 | + if not expect_directory | |
| 677 | + and planned_artifact_target_satisfied( | |
| 678 | + dod, | |
| 679 | + target=target, | |
| 680 | + expect_directory=False, | |
| 681 | + project_root=self.context.project_root, | |
| 682 | + ) | |
| 683 | + ) | |
| 684 | + | |
| 662 | 685 | def _next_step_resume_lines( |
| 663 | 686 | self, |
| 664 | 687 | dod: DefinitionOfDone, |
tests/test_repair.pymodified@@ -947,6 +947,7 @@ def test_empty_response_retry_prefers_pending_index_over_broad_directory_headlin | ||
| 947 | 947 | in decision.retry_message |
| 948 | 948 | ) |
| 949 | 949 | assert "Next missing planned artifact: `chapters/`" not in decision.retry_message |
| 950 | + assert "Remaining planned artifacts:" not in decision.retry_message | |
| 950 | 951 | assert ( |
| 951 | 952 | "Next observed output pattern under `chapters/`: `01-introduction.html`" |
| 952 | 953 | not in decision.retry_message |
@@ -1018,6 +1019,7 @@ def test_empty_response_retry_uses_concrete_file_language_for_aggregate_chapter_ | ||
| 1018 | 1019 | "It is the next concrete output needed to continue `Create chapter files with content and structure`." |
| 1019 | 1020 | in decision.retry_message |
| 1020 | 1021 | ) |
| 1022 | + assert "Remaining planned artifacts:" not in decision.retry_message | |
| 1021 | 1023 | assert ( |
| 1022 | 1024 | "continue `Create chapter files with content and structure` by creating `01-introduction.html`." |
| 1023 | 1025 | not in decision.retry_message |