tenseleyflow/loader / ab475b4

Browse files

Compact early output handoffs

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
ab475b484e7a24f3264dfe8a02db65bdfc1832cd
Parents
720cf3c
Tree
5b203c9

2 changed files

StatusFile+-
M src/loader/runtime/tool_batches.py 26 0
M tests/test_tool_batches.py 18 40
src/loader/runtime/tool_batches.pymodified
@@ -1186,6 +1186,18 @@ class ToolBatchRunner:
11861186
                 and resume_target is not None
11871187
                 and resume_target.suffix
11881188
             ):
1189
+                compact_resume = _compact_missing_artifact_handoff(
1190
+                    (resume_target, False),
1191
+                    project_root=self.context.project_root,
1192
+                    messages=list(getattr(self.context.session, "messages", []) or []),
1193
+                )
1194
+                if compact_resume:
1195
+                    self.context.queue_steering_message(
1196
+                        "Directory setup is complete. "
1197
+                        + compact_resume
1198
+                        + " Do not reread older reference files before that mutation."
1199
+                    )
1200
+                    return
11891201
                 self.context.queue_steering_message(
11901202
                     f"Directory setup is complete. Continue with the next pending item: `{next_pending}`."
11911203
                     + resume_suffix
@@ -1389,6 +1401,20 @@ class ToolBatchRunner:
13891401
             pending_target=pending_target,
13901402
             resume_target=resume_target,
13911403
         )
1404
+        if resume_target is not None and resume_target.suffix:
1405
+            compact_resume = _compact_missing_artifact_handoff(
1406
+                (resume_target, False),
1407
+                project_root=self.context.project_root,
1408
+                messages=session_messages,
1409
+            )
1410
+            if compact_resume:
1411
+                self.context.queue_steering_message(
1412
+                    "Todo tracking is updated. "
1413
+                    + compact_resume
1414
+                    + " Do not spend the next turn on TodoWrite alone, bookkeeping notes, "
1415
+                    "verification, or final confirmation until that artifact exists."
1416
+                )
1417
+                return
13921418
         self.context.queue_steering_message(
13931419
             "Todo tracking is updated. A declared output artifact is still missing."
13941420
             + next_pending_suffix
tests/test_tool_batches.pymodified
@@ -2243,8 +2243,7 @@ async def test_tool_batch_runner_missing_artifact_nudge_names_next_file_after_se
22432243
     assert persistent_messages
22442244
     message = persistent_messages[-1]
22452245
     assert "Directory setup is complete." in message
2246
-    assert "Continue with the next pending item: `Develop the main index.html file with proper structure`." in message
2247
-    assert "Resume by creating `index.html` now." in message
2246
+    assert "Next step: create `index.html`." in message
22482247
     assert ephemeral_messages == []
22492248
 
22502249
 
@@ -2712,8 +2711,8 @@ async def test_tool_batch_runner_todowrite_uses_concrete_output_language_for_agg
27122711
 
27132712
     assert queued_messages
27142713
     message = queued_messages[-1]
2715
-    assert "Continue with the next concrete output: `01-introduction.html`." in message
2716
-    assert "Resume by creating `01-introduction.html` now." in message
2714
+    assert "Todo tracking is updated." in message
2715
+    assert "Next step: create `01-introduction.html`." in message
27172716
     assert (
27182717
         "Continue with the next pending item: `Create chapter files with content and structure`."
27192718
         not in message
@@ -3435,10 +3434,9 @@ async def test_tool_batch_runner_todowrite_with_missing_artifact_requeues_exact_
34353434
 
34363435
     assert persistent_messages
34373436
     message = persistent_messages[-1]
3438
-    assert "Todo tracking is updated. A declared output artifact is still missing." in message
3439
-    assert "Resume by creating `02-installation.html` now." in message
3440
-    assert "refresh `TodoWrite`" in message
3441
-    assert "Do not spend the next turn on TodoWrite alone" in message
3437
+    assert "Todo tracking is updated. Next step: create `02-installation.html`." in message
3438
+    assert "Prefer one `write(file_path=..., content=...)` call" in message
3439
+    assert "Make your next response the concrete mutation tool call itself." in message
34423440
     assert ephemeral_messages == []
34433441
 
34443442
 
@@ -3744,12 +3742,9 @@ async def test_tool_batch_runner_todowrite_with_existing_output_roots_requeues_n
37443742
 
37453743
     assert queued_messages
37463744
     message = queued_messages[-1]
3747
-    assert "Todo tracking is updated. A declared output artifact is still missing." in message
3748
-    assert "Continue with the next pending item: `Write the introduction chapter`." in message
3749
-    assert "Resume by creating `01-introduction.html` now." in message
3750
-    assert "Prefer one `write` call for `" in message
3751
-    assert "01-introduction.html` instead of more rereads." in message
3752
-    assert "Do not spend the next turn on TodoWrite alone" in message
3745
+    assert "Todo tracking is updated. Next step: create `01-introduction.html`." in message
3746
+    assert "Prefer one `write(file_path=..., content=...)` call" in message
3747
+    assert "Make your next response the concrete mutation tool call itself." in message
37533748
 
37543749
 
37553750
 @pytest.mark.asyncio
@@ -3885,9 +3880,8 @@ async def test_tool_batch_runner_todowrite_prefers_pending_index_over_empty_outp
38853880
 
38863881
     assert queued_messages
38873882
     message = queued_messages[-1]
3888
-    assert "Continue with the next pending item: `Create a new index.html for the nginx guide`." in message
3889
-    assert "Resume by creating `index.html` now." in message
3890
-    assert f"Prefer one `write` call for `{index_path.resolve(strict=False)}`" in message
3883
+    assert "Todo tracking is updated. Next step: create `index.html`." in message
3884
+    assert f"Prefer one `write(file_path=..., content=...)` call for `{index_path.resolve(strict=False)}`" in message
38913885
     assert "01-introduction.html" not in message
38923886
 
38933887
 
@@ -4011,12 +4005,9 @@ async def test_tool_batch_runner_todowrite_with_declared_child_targets_names_nex
40114005
 
40124006
     assert queued_messages
40134007
     message = queued_messages[-1]
4014
-    assert "Todo tracking is updated. A declared output artifact is still missing." in message
4015
-    assert "Continue with the next pending item: `Write the introduction chapter`." in message
4016
-    assert "Resume by creating `introduction.html` now." in message
4017
-    assert "Prefer one `write` call for `" in message
4018
-    assert "introduction.html` instead of more rereads." in message
4019
-    assert "Do not spend the next turn on TodoWrite alone" in message
4008
+    assert "Todo tracking is updated. Next step: create `introduction.html`." in message
4009
+    assert "Prefer one `write(file_path=..., content=...)` call" in message
4010
+    assert "Make your next response the concrete mutation tool call itself." in message
40204011
 
40214012
 
40224013
 @pytest.mark.asyncio
@@ -4141,14 +4132,8 @@ async def test_tool_batch_runner_todowrite_names_concrete_pending_file_after_art
41414132
 
41424133
     assert queued_messages
41434134
     message = queued_messages[-1]
4144
-    assert "Todo tracking is updated. A declared output artifact is still missing." in message
4145
-    assert "Continue with the next pending item: `Creating Chapter 2: Installation and Setup`." in message
4146
-    assert "Resume by creating `02-installation.html` now." in message
4147
-    assert (
4148
-        f"Prefer one `write` call for `{(chapters / '02-installation.html').resolve(strict=False)}` "
4149
-        "instead of more rereads."
4150
-        in message
4151
-    )
4135
+    assert "Todo tracking is updated. Next step: create `02-installation.html`." in message
4136
+    assert "Prefer one `write(file_path=..., content=...)` call" in message
41524137
     assert "Make your next response the concrete mutation tool call itself" in message
41534138
 
41544139
 
@@ -4278,15 +4263,8 @@ async def test_tool_batch_runner_todowrite_uses_observed_sibling_pattern_for_nex
42784263
 
42794264
     assert queued_messages
42804265
     message = queued_messages[-1]
4281
-    assert "Todo tracking is updated. A declared output artifact is still missing." in message
4282
-    assert "Continue with the next pending item: `Write the introduction chapter`." in message
4283
-    assert "Resume by creating `01-introduction.html` now." in message
4284
-    assert (
4285
-        "It mirrors the observed filename pattern from another `chapters/` directory "
4286
-        "you already inspected."
4287
-        in message
4288
-    )
4289
-    assert "01-introduction.html` instead of more rereads." in message
4266
+    assert "Todo tracking is updated. Next step: create `01-introduction.html`." in message
4267
+    assert "Prefer one `write(file_path=..., content=...)` call" in message
42904268
 
42914269
 
42924270
 @pytest.mark.asyncio