tenseleyflow/loader / c84cfd5

Browse files

Compact first file handoff

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c84cfd5bcd77d67f4d3d07304b34297ad8ddaa57
Parents
aa4c3b0
Tree
17b2f9f

2 changed files

StatusFile+-
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:
11061106
             dod,
11071107
             project_root=self.context.project_root,
11081108
         )
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
+        )
11091116
         resume_suffix = _pending_item_resume_suffix(
11101117
             dod,
11111118
             next_pending=next_pending,
@@ -1113,14 +1120,32 @@ class ToolBatchRunner:
11131120
             project_root=self.context.project_root,
11141121
             messages=list(getattr(self.context.session, "messages", []) or []),
11151122
         )
1123
+        use_persistent_handoff = _should_use_persistent_missing_artifact_handoff(
1124
+            dod,
1125
+            project_root=self.context.project_root,
1126
+        )
11161127
         queue_message = (
11171128
             self.context.queue_steering_message
1118
-            if _should_use_persistent_missing_artifact_handoff(
1119
-                dod,
1120
-                project_root=self.context.project_root,
1121
-            )
1129
+            if use_persistent_handoff
11221130
             else self.context.queue_ephemeral_steering_message
11231131
         )
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
11241149
         todo_refresh = _todo_refresh_guidance(
11251150
             dod,
11261151
             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(
22382238
     assert persistent_messages
22392239
     message = persistent_messages[-1]
22402240
     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
22422242
     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."
22452244
         in message
22462245
     )
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
22482247
     assert ephemeral_messages == []
22492248
 
22502249
 
@@ -2564,10 +2563,13 @@ async def test_tool_batch_runner_mutation_handoff_points_at_next_missing_artifac
25642563
 
25652564
     assert queued_messages
25662565
     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
25712573
 
25722574
 
25732575
 @pytest.mark.asyncio