Compact first file handoff
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
c84cfd5bcd77d67f4d3d07304b34297ad8ddaa57- Parents
-
aa4c3b0 - Tree
17b2f9f
c84cfd5
c84cfd5bcd77d67f4d3d07304b34297ad8ddaa57aa4c3b0
17b2f9f| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/runtime/tool_batches.py
|
29 | 4 |
| M |
tests/test_tool_batches.py
|
10 | 8 |
src/loader/runtime/tool_batches.pymodified@@ -1106,6 +1106,13 @@ class ToolBatchRunner: | ||
| 1106 | 1106 | dod, |
| 1107 | 1107 | project_root=self.context.project_root, |
| 1108 | 1108 | ) |
| 1109 | + resume_target = _preferred_resume_target_path( | |
| 1110 | + dod, | |
| 1111 | + next_pending=next_pending, | |
| 1112 | + missing_artifact=missing_artifact, | |
| 1113 | + project_root=self.context.project_root, | |
| 1114 | + messages=list(getattr(self.context.session, "messages", []) or []), | |
| 1115 | + ) | |
| 1109 | 1116 | resume_suffix = _pending_item_resume_suffix( |
| 1110 | 1117 | dod, |
| 1111 | 1118 | next_pending=next_pending, |
@@ -1113,14 +1120,32 @@ class ToolBatchRunner: | ||
| 1113 | 1120 | project_root=self.context.project_root, |
| 1114 | 1121 | messages=list(getattr(self.context.session, "messages", []) or []), |
| 1115 | 1122 | ) |
| 1116 | - queue_message = ( | |
| 1117 | - self.context.queue_steering_message | |
| 1118 | - if _should_use_persistent_missing_artifact_handoff( | |
| 1123 | + use_persistent_handoff = _should_use_persistent_missing_artifact_handoff( | |
| 1119 | 1124 | dod, |
| 1120 | 1125 | project_root=self.context.project_root, |
| 1121 | 1126 | ) |
| 1127 | + queue_message = ( | |
| 1128 | + self.context.queue_steering_message | |
| 1129 | + if use_persistent_handoff | |
| 1122 | 1130 | else self.context.queue_ephemeral_steering_message |
| 1123 | 1131 | ) |
| 1132 | + if ( | |
| 1133 | + use_persistent_handoff | |
| 1134 | + and resume_target is not None | |
| 1135 | + and resume_target.suffix | |
| 1136 | + ): | |
| 1137 | + compact_resume = _compact_missing_artifact_handoff( | |
| 1138 | + (resume_target, False), | |
| 1139 | + project_root=self.context.project_root, | |
| 1140 | + messages=list(getattr(self.context.session, "messages", []) or []), | |
| 1141 | + ) | |
| 1142 | + if compact_resume: | |
| 1143 | + queue_message( | |
| 1144 | + f"Confirmed progress: {current_label} is now recorded. " | |
| 1145 | + + compact_resume | |
| 1146 | + + " Do not reread reference material or spend the next turn on bookkeeping." | |
| 1147 | + ) | |
| 1148 | + return | |
| 1124 | 1149 | todo_refresh = _todo_refresh_guidance( |
| 1125 | 1150 | dod, |
| 1126 | 1151 | project_root=self.context.project_root, |
tests/test_tool_batches.pymodified@@ -2238,13 +2238,12 @@ async def test_tool_batch_runner_first_file_handoff_stays_persistent( | ||
| 2238 | 2238 | assert persistent_messages |
| 2239 | 2239 | message = persistent_messages[-1] |
| 2240 | 2240 | assert "Confirmed progress:" in message |
| 2241 | - assert "Resume by creating `01-introduction.html` now." in message | |
| 2241 | + assert "Next step: create `01-introduction.html`." in message | |
| 2242 | 2242 | assert ( |
| 2243 | - f"Prefer one `write` call for `{(chapters / '01-introduction.html').resolve(strict=False)}` " | |
| 2244 | - "instead of more rereads." | |
| 2243 | + f"Prefer one `write(file_path=..., content=...)` call for `{(chapters / '01-introduction.html').resolve(strict=False)}` now." | |
| 2245 | 2244 | in message |
| 2246 | 2245 | ) |
| 2247 | - assert "Do not move to verification, final confirmation, or TodoWrite-only bookkeeping" in message | |
| 2246 | + assert "Do not reread reference material or spend the next turn on bookkeeping." in message | |
| 2248 | 2247 | assert ephemeral_messages == [] |
| 2249 | 2248 | |
| 2250 | 2249 | |
@@ -2564,10 +2563,13 @@ async def test_tool_batch_runner_mutation_handoff_points_at_next_missing_artifac | ||
| 2564 | 2563 | |
| 2565 | 2564 | assert queued_messages |
| 2566 | 2565 | message = queued_messages[-1] |
| 2567 | - assert "Resume by creating `01-getting-started.html` now." in message | |
| 2568 | - assert "refresh `TodoWrite`" in message | |
| 2569 | - assert "Do not move to verification, final confirmation, or TodoWrite-only bookkeeping" in message | |
| 2570 | - assert "Do not spend another turn on working notes or rediscovery alone." in message | |
| 2566 | + assert "Next step: create `01-getting-started.html`." in message | |
| 2567 | + assert ( | |
| 2568 | + f"Prefer one `write(file_path=..., content=...)` call for `{chapter_one.resolve(strict=False)}` now." | |
| 2569 | + in message | |
| 2570 | + ) | |
| 2571 | + assert "refresh `TodoWrite`" not in message | |
| 2572 | + assert "Do not reread reference material or spend the next turn on bookkeeping." in message | |
| 2571 | 2573 | |
| 2572 | 2574 | |
| 2573 | 2575 | @pytest.mark.asyncio |