ralph-workflow 0.7.18

PROMPT-driven multi-agent orchestrator for git repos
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
// Tests for developer prompts.

use super::*;

#[test]
fn test_prompt_developer_iteration() {
    let result = prompt_developer_iteration(2, 5, ContextLevel::Normal, "test prompt", "test plan");
    // Agent should receive PROMPT and PLAN content directly
    assert!(result.contains("test prompt"));
    assert!(result.contains("test plan"));
    assert!(result.contains("IMPLEMENTATION MODE"));
    // Agent should NOT be told to read PROMPT.md (orchestrator handles it)
    assert!(!result.contains("PROMPT.md"));
    assert!(!result.contains("PLAN.md"));
    assert!(
        result.contains("Do NOT create STATUS.md")
            && result.contains("CURRENT_STATUS.md")
            && result.contains("CURRENT_IMPLEMENTATION.md"),
        "Prompt should explicitly ban status/handoff files"
    );
    assert!(
        result.contains("Do NOT write summaries")
            || result.contains("Do NOT attempt to communicate"),
        "Prompt should clearly ban result-summary communication"
    );
    assert!(
        !result.contains("may or may not be shown to the user"),
        "Prompt should avoid speculative next-step context"
    );
}

#[test]
fn test_developer_iteration_minimal_context() {
    let result =
        prompt_developer_iteration(1, 5, ContextLevel::Minimal, "test prompt", "test plan");
    // Minimal context should include essential files (not STATUS.md in isolation mode)
    // Agent should receive PROMPT and PLAN content directly
    assert!(result.contains("test prompt"));
    assert!(result.contains("test plan"));
    // Agent should NOT be told to read PROMPT.md (orchestrator handles it)
    assert!(!result.contains("PROMPT.md"));
    assert!(!result.contains("PLAN.md"));
    assert!(
        result.contains("Do NOT create STATUS.md")
            && result.contains("CURRENT_STATUS.md")
            && result.contains("CURRENT_IMPLEMENTATION.md"),
        "Prompt should explicitly ban status/handoff files"
    );
}

#[test]
fn test_prompt_plan() {
    let result = prompt_plan(None);
    // Prompt should NOT explicitly mention PROMPT.md file name
    // Agents receive content directly without knowing the source file
    assert!(!result.contains("PROMPT.md"));
    assert!(!result.contains("NEVER read, write, or delete this file"));
    // Plan is now returned as XML output format
    assert!(result.contains("PLANNING MODE"));
    assert!(result.contains("<ralph-implementation-steps>"));
    assert!(result.contains("<ralph-critical-files>"));
    assert!(result.contains("<ralph-verification-strategy>"));

    // Ensure strict read-only constraints are present (Claude Code alignment)
    assert!(result.contains("READ-ONLY"));
    assert!(result.contains("STRICTLY PROHIBITED"));

    // Ensure 5-phase workflow structure (Claude Code alignment)
    assert!(result.contains("PHASE 1: UNDERSTANDING"));
    assert!(result.contains("PHASE 2: EXPLORATION"));
    assert!(result.contains("PHASE 3: DESIGN"));
    assert!(result.contains("PHASE 4: REVIEW"));
    assert!(result.contains("PHASE 5: WRITE STRUCTURED PLAN"));

    // Ensure XML output format is specified
    assert!(result.contains("<ralph-plan>"));
    assert!(result.contains("<ralph-summary>"));
}

#[test]
fn test_prompt_plan_with_content() {
    let prompt_md = "# Test Prompt\n\nThis is the content.";
    let result = prompt_plan(Some(prompt_md));
    // Should include the content WITHOUT naming PROMPT.md
    assert!(result.contains("USER REQUIREMENTS:"));
    assert!(result.contains("This is the content."));
    // Should NOT mention PROMPT.md file name
    assert!(!result.contains("PROMPT.md"));
    // Should still have the planning structure
    assert!(result.contains("PLANNING MODE"));
    assert!(result.contains("PHASE 1: UNDERSTANDING"));
    // Should have XML output format
    assert!(result.contains("<ralph-plan>"));
}

#[test]
fn all_developer_prompts_isolate_agents_from_git() {
    // Verify developer prompts prohibit mutating git commands.
    // Read-only lookup examples (git status/git diff) are allowed when explicitly scoped.
    let prompts = vec![
        prompt_developer_iteration(1, 3, ContextLevel::Minimal, "", ""),
        prompt_developer_iteration(2, 3, ContextLevel::Normal, "", ""),
        prompt_plan(None),
    ];

    for prompt in prompts {
        assert!(
            !prompt.contains("git commit"),
            "Developer prompt should not tell agent to run git commit"
        );
        assert!(
            !prompt.contains("git add"),
            "Developer prompt should not tell agent to run git add"
        );

        if prompt.contains("git status") || prompt.contains("git diff") {
            assert!(
                prompt.contains("Do NOT run ANY git command except read-only lookup commands"),
                "git status/git diff references must appear only in read-only allowlist context"
            );
        }
    }
}

#[test]
fn test_prompt_developer_iteration_with_context() {
    let context = TemplateContext::default();
    let result = prompt_developer_iteration_with_context(
        &context,
        2,
        5,
        ContextLevel::Normal,
        "test prompt",
        "test plan",
    );
    // Agent should receive PROMPT and PLAN content directly
    assert!(result.contains("test prompt"));
    assert!(result.contains("test plan"));
    assert!(result.contains("IMPLEMENTATION MODE"));
    // Agent should NOT be told to read PROMPT.md (orchestrator handles it)
    assert!(!result.contains("PROMPT.md"));
    assert!(!result.contains("PLAN.md"));
}

#[test]
fn test_prompt_developer_iteration_with_context_minimal() {
    let context = TemplateContext::default();
    let result = prompt_developer_iteration_with_context(
        &context,
        1,
        5,
        ContextLevel::Minimal,
        "test prompt",
        "test plan",
    );
    // Agent should receive PROMPT and PLAN content directly
    assert!(result.contains("test prompt"));
    assert!(result.contains("test plan"));
    assert!(!result.contains("PROMPT.md"));
    assert!(!result.contains("PLAN.md"));
}

#[test]
fn test_prompt_plan_with_context() {
    use crate::workspace::MemoryWorkspace;
    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();
    let result = prompt_plan_with_context(&context, None, &workspace);
    assert!(result.contains("PLANNING MODE"));
    assert!(result.contains("<ralph-implementation-steps>"));
    assert!(result.contains("<ralph-critical-files>"));
    assert!(result.contains("<ralph-verification-strategy>"));
    assert!(result.contains("READ-ONLY"));
    assert!(result.contains("STRICTLY PROHIBITED"));
    assert!(result.contains("PHASE 1: UNDERSTANDING"));
    assert!(result.contains("PHASE 2: EXPLORATION"));
    assert!(result.contains("PHASE 3: DESIGN"));
    assert!(result.contains("PHASE 4: REVIEW"));
    assert!(result.contains("PHASE 5: WRITE STRUCTURED PLAN"));
    assert!(result.contains("<ralph-plan>"));
    assert!(
        result.contains(
            "Choose a complete solution that fixes the problem at the root cause. Do not plan surface-level fixes or partial implementations."
        ),
        "Planning prompt should center design guidance on complete root-cause solutions"
    );
    assert!(
        !result.contains("Prefer the simplest approach that satisfies all requirements."),
        "Planning prompt should not bias toward simplistic approaches"
    );
}

#[test]
fn test_prompt_plan_with_context_uses_progress_based_anti_runaway_policy() {
    use crate::workspace::MemoryWorkspace;

    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();
    let result = prompt_plan_with_context(&context, None, &workspace);

    assert!(
        result.contains("ANTI-RUNAWAY POLICY") && result.contains("PROGRESS-BASED"),
        "Planning prompt should require a progress-based anti-runaway policy"
    );
    assert!(
        result.contains("required_sections")
            && result.contains("objective")
            && result.contains("scope")
            && result.contains("steps")
            && result.contains("risks")
            && result.contains("verification"),
        "Planning prompt should define goal-coverage gates for required sections"
    );
    assert!(
        result.contains("unresolved_unknowns") && result.contains("max 3"),
        "Planning prompt should cap unresolved unknowns"
    );
    assert!(
        result.contains("stagnation_count") && result.contains("no materially new info"),
        "Planning prompt should track stagnation based on novelty"
    );
    assert!(
        result.contains("stagnation_count reaches 2")
            && result.contains("stop exploration")
            && result.contains("start drafting"),
        "Planning prompt should force draft mode after repeated non-novel exploration"
    );
    assert!(
        result.contains("convert extras into explicit investigation steps"),
        "Planning prompt should convert excess unknowns into explicit investigation steps"
    );
    assert!(
        result.contains("one critique pass"),
        "Planning prompt should include a bounded critique stage"
    );
    assert!(
        result.contains("at most one targeted re-exploration pass"),
        "Planning prompt should cap critique-driven re-exploration"
    );
    assert!(
        result.contains("Then finalize plan") && result.contains("no further exploration allowed"),
        "Planning prompt should hard-stop exploration after finalization"
    );
    assert!(
        result.contains("open questions")
            && result.contains("research")
            && result.contains("explicit investigation"),
        "Planning prompt should convert open questions/unknowns into explicit research steps when needed"
    );
    assert!(
        !result.contains("MAX 50 read/search operations"),
        "Planning prompt should avoid fixed operation hard caps"
    );
}

#[test]
fn test_prompt_plan_with_context_is_concise_and_non_redundant() {
    use crate::workspace::MemoryWorkspace;

    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();
    let result = prompt_plan_with_context(&context, None, &workspace);

    assert!(
        !result.contains("OPENCODE") && !result.contains("Claude"),
        "Planning prompt should avoid external branding/style references"
    );
    assert!(
        result.contains("READ-ONLY") && result.contains("STRICTLY PROHIBITED"),
        "Planning prompt must keep explicit read-only constraints"
    );
    assert!(
        result.contains("non-mutating") || result.contains("image"),
        "Planning prompt should allow non-mutating tooling like file reading and image analysis"
    );
}

#[test]
fn test_prompt_plan_with_context_and_content() {
    use crate::workspace::MemoryWorkspace;
    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();
    let prompt_md = "# Test Prompt\n\nThis is the content.";
    let result = prompt_plan_with_context(&context, Some(prompt_md), &workspace);
    assert!(result.contains("USER REQUIREMENTS:"));
    assert!(result.contains("This is the content."));
    assert!(!result.contains("PROMPT.md"));
    assert!(result.contains("PLANNING MODE"));
    assert!(result.contains("PHASE 1: UNDERSTANDING"));
}

#[test]
fn test_context_based_prompts_isolate_from_git() {
    use crate::workspace::MemoryWorkspace;
    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();
    let prompts = vec![
        prompt_developer_iteration_with_context(&context, 1, 3, ContextLevel::Minimal, "", ""),
        prompt_developer_iteration_with_context(&context, 2, 3, ContextLevel::Normal, "", ""),
        prompt_plan_with_context(&context, None, &workspace),
    ];

    for prompt in prompts {
        assert!(
            !prompt.contains("git commit"),
            "Developer prompt should not tell agent to run git commit"
        );
        assert!(
            !prompt.contains("git add"),
            "Developer prompt should not tell agent to run git add"
        );

        if prompt.contains("git status") || prompt.contains("git diff") {
            assert!(
                prompt.contains("Do NOT run ANY git command except read-only lookup commands"),
                "git status/git diff references must appear only in read-only allowlist context"
            );
        }
    }
}

#[test]
fn test_context_based_uses_workspace_rooted_paths() {
    use crate::workspace::MemoryWorkspace;

    // Create a workspace with a different root than current_dir
    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();

    // Test that context-based planning function uses workspace-rooted paths
    let with_context_plan = prompt_plan_with_context(&context, None, &workspace);

    // The output should contain absolute paths rooted at the workspace
    // not at the process current_dir()
    let workspace_root = workspace.root().to_string_lossy();
    if with_context_plan.contains(".agent/tmp/plan.xml") {
        // If the path is in the output, verify it's workspace-rooted
        assert!(
            with_context_plan.contains(workspace_root.as_ref()),
            "Context-based prompt should use workspace-rooted paths, found plan path without workspace root"
        );
    }

    // Test that context-based developer iteration function works correctly
    let _with_context_dev = prompt_developer_iteration_with_context(
        &context,
        1,
        3,
        ContextLevel::Normal,
        "prompt",
        "plan",
    );

    let xsd_retry_workspace = MemoryWorkspace::new_test().with_file(
        ".agent/tmp/last_output.xml",
        "<ralph-development-result><ralph-status>partial</ralph-status></ralph-development-result>",
    );
    let continuation_xsd_retry = prompt_developer_iteration_xsd_retry_with_context_files(
        &context,
        "Test error",
        &xsd_retry_workspace,
        true,
    );
    assert!(
        continuation_xsd_retry.contains("development_result.xsd"),
        "Continuation-mode XSD retry should point at development_result.xsd"
    );
    let referenced_schemas: Vec<&str> = continuation_xsd_retry
        .split(|ch: char| !(ch.is_ascii_alphanumeric() || ch == '_' || ch == '.' || ch == '/'))
        .filter(|token| token.ends_with(".xsd"))
        .collect();
    assert!(
        referenced_schemas
            .iter()
            .all(|schema| schema.ends_with("development_result.xsd")),
        "Continuation-mode XSD retry must only reference the canonical development_result.xsd schema"
    );

    // Both should contain the core content (PROMPT and PLAN)
    // The context-based version is designed to be the production API
    assert!(with_context_plan.contains("PLANNING MODE"));
}

#[test]
fn test_continuation_xsd_retry_uses_continuation_specific_instructions() {
    use crate::workspace::MemoryWorkspace;

    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test().with_file(
        ".agent/tmp/last_output.xml",
        "<ralph-development-result><ralph-status>completed</ralph-status></ralph-development-result>",
    );

    let prompt = prompt_developer_iteration_xsd_retry_with_context_files(
        &context,
        "Continuation output validation error",
        &workspace,
        true,
    );

    assert!(
        prompt.contains("development_result.xsd"),
        "Continuation-mode XSD retry should point at development_result.xsd"
    );
    let referenced_schemas: Vec<&str> = prompt
        .split(|ch: char| !(ch.is_ascii_alphanumeric() || ch == '_' || ch == '.' || ch == '/'))
        .filter(|token| token.ends_with(".xsd"))
        .collect();
    assert!(
        referenced_schemas
            .iter()
            .all(|schema| schema.ends_with("development_result.xsd")),
        "Continuation-mode XSD retry must only reference the canonical development_result.xsd schema"
    );
    assert!(
        prompt.contains("continuation output")
            || prompt.contains("continuation XML")
            || prompt.contains("recovery-critical information"),
        "Continuation-mode XSD retry should explicitly describe continuation output requirements"
    );
    assert!(
        !prompt.contains("Fix ONLY the XML structure/format issues"),
        "Continuation-mode XSD retry must not instruct the agent to only fix generic XML formatting"
    );
    assert!(
        !prompt.contains("Change the content/meaning of your response - ONLY fix the XML format"),
        "Continuation-mode XSD retry must allow semantic contract fixes required by continuation validation"
    );
}

#[test]
fn test_xsd_retry_source_has_canonical_status_and_schema_guards() {
    let source = include_str!("system_prompt_iteration_xsd_retry.rs");
    let referenced_schemas: Vec<&str> = source
        .split(|ch: char| !(ch.is_ascii_alphanumeric() || ch == '_' || ch == '.' || ch == '/'))
        .filter(|token| token.ends_with(".xsd"))
        .collect();

    assert!(
        source.contains("development_result.xsd"),
        "Developer XSD retry source must reference the canonical development_result.xsd path"
    );
    assert!(
        referenced_schemas
            .iter()
            .all(|schema| schema.ends_with("development_result.xsd")
                || schema.ends_with("fix_result.xsd")),
        "Developer XSD retry source must only reference canonical XSD paths"
    );
    assert!(
        source.contains("<ralph-status>completed|partial|failed</ralph-status>"),
        "Developer XSD retry source must keep completed|partial|failed status contract"
    );
    assert!(
        !source.contains(concat!(
            "<ralph-status>",
            "partial|failed",
            "</ralph-status>"
        )),
        "Developer XSD retry source must not regress to partial|failed-only status contract"
    );
}

#[test]
fn test_xsd_retry_falls_back_when_last_output_is_missing() {
    use crate::workspace::MemoryWorkspace;

    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();

    let prompt = prompt_developer_iteration_xsd_retry_with_context_files(
        &context,
        "Missing previous output",
        &workspace,
        false,
    );

    assert!(
        prompt.contains("FIX XML ONLY"),
        "Fallback prompt should clearly frame the retry as an XML-only correction"
    );
    assert!(
        prompt.contains("Do NOT redo analysis or implementation work"),
        "Fallback prompt should keep the agent in the same session and avoid analysis rework"
    );
}

#[test]
fn test_continuation_xsd_retry_with_log_falls_back_when_last_output_is_missing() {
    use crate::workspace::MemoryWorkspace;
    use tempfile::tempdir;

    let template_dir = tempdir().expect("create temp template dir");
    std::fs::write(
        template_dir
            .path()
            .join("developer_iteration_xsd_retry.txt"),
        "custom template {{XSD_ERROR}} {{DEVELOPMENT_RESULT_XSD_PATH}} {{LAST_OUTPUT_XML_PATH}}",
    )
    .expect("write custom xsd retry template");

    let context = TemplateContext::from_user_templates_dir(Some(template_dir.path().to_path_buf()));
    let workspace = MemoryWorkspace::new_test();

    let rendered = prompt_developer_iteration_xsd_retry_with_context_files_and_log(
        &context,
        "Missing continuation last output",
        &workspace,
        "developer_iteration_xsd_retry",
        true,
    );

    assert!(
        rendered.content.contains("FIX XML ONLY"),
        "Logged fallback prompt should clearly frame retries as XML-only corrections"
    );
    assert!(
        rendered.content.contains("Do NOT redo analysis or implementation work"),
        "Logged fallback prompt should keep the agent in the same session and avoid analysis rework"
    );
    assert!(
        !rendered.content.contains("custom template"),
        "Fallback path should not render the normal template when required retry context is missing"
    );
}

#[test]
fn test_regular_functions_use_cwd_rooted_paths() {
    use std::env;

    // Test that regular (test-only) functions use current_dir
    let regular_plan = prompt_plan(None);

    // The regular function uses WorkspaceFs::new(env::current_dir())
    // so paths are rooted at CWD
    let binding = env::current_dir().unwrap();
    let cwd = binding.to_string_lossy();
    if regular_plan.contains(".agent/tmp/plan.xml") {
        // The path should be rooted at CWD, not necessarily at a workspace root
        // This is the test-only legacy behavior
        assert!(
            regular_plan.contains(cwd.as_ref()) || regular_plan.contains("/tmp/"),
            "Regular prompt function should use CWD-rooted paths (test-only legacy behavior)"
        );
    }
}

#[test]
fn test_prompt_developer_iteration_xml_with_context_renders_shared_partials() {
    use crate::workspace::MemoryWorkspace;
    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();

    let result = prompt_developer_iteration_xml_with_context(
        &context,
        "test prompt",
        "test plan",
        &workspace,
    );

    assert!(result.contains("test prompt"));
    assert!(result.contains("test plan"));
    assert!(result.contains("IMPLEMENTATION MODE"));

    // Shared partials should be expanded
    assert!(
        result.contains("*** UNATTENDED MODE - NO USER INTERACTION ***"),
        "developer_iteration_xml should render shared/_unattended_mode partial"
    );
    assert!(
        !result.contains("{{>"),
        "developer_iteration_xml should not contain raw partial directives"
    );
}

// =========================================================================
// Tests for _with_references variants
// =========================================================================

#[test]
fn test_prompt_developer_iteration_xml_with_references_small_content() {
    use crate::prompts::content_builder::PromptContentBuilder;
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test();
    let context = TemplateContext::default();

    let refs = PromptContentBuilder::new(&workspace)
        .with_prompt("Small prompt content".to_string())
        .with_plan("Small plan content".to_string())
        .build();

    let result = prompt_developer_iteration_xml_with_references(&context, &refs, &workspace);

    // Should embed content inline
    assert!(result.contains("Small prompt content"));
    assert!(result.contains("Small plan content"));
    assert!(result.contains("IMPLEMENTATION MODE"));

    // Shared partials should be expanded
    assert!(
        result.contains("*** UNATTENDED MODE - NO USER INTERACTION ***"),
        "developer_iteration_xml should render shared/_unattended_mode partial"
    );
    assert!(
        !result.contains("{{>"),
        "developer_iteration_xml should not contain raw partial directives"
    );
}

#[test]
fn test_prompt_developer_iteration_xml_with_references_large_prompt() {
    use crate::prompts::content_builder::PromptContentBuilder;
    use crate::prompts::content_reference::MAX_INLINE_CONTENT_SIZE;
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test().with_file(".agent/PROMPT.md.backup", "backup");

    let context = TemplateContext::default();
    let large_prompt = "x".repeat(MAX_INLINE_CONTENT_SIZE + 1);

    let refs = PromptContentBuilder::new(&workspace)
        .with_prompt(large_prompt)
        .with_plan("Small plan".to_string())
        .build();

    let result = prompt_developer_iteration_xml_with_references(&context, &refs, &workspace);

    // Should reference backup file, not embed content
    assert!(result.contains("PROMPT.md.backup"));
    assert!(result.contains("Read from"));
    assert!(result.contains("Small plan"));
}

#[test]
fn test_prompt_developer_iteration_xml_with_references_large_plan() {
    use crate::prompts::content_builder::PromptContentBuilder;
    use crate::prompts::content_reference::MAX_INLINE_CONTENT_SIZE;
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test();
    let context = TemplateContext::default();
    let large_plan = "p".repeat(MAX_INLINE_CONTENT_SIZE + 1);

    let refs = PromptContentBuilder::new(&workspace)
        .with_prompt("Small prompt".to_string())
        .with_plan(large_plan)
        .build();

    let result = prompt_developer_iteration_xml_with_references(&context, &refs, &workspace);

    // Should reference PLAN.md file, not embed content
    assert!(result.contains(".agent/PLAN.md"));
    assert!(result.contains("plan.xml"));
    assert!(result.contains("Small prompt"));
}

#[test]
fn test_prompt_planning_xml_with_references_small_content() {
    use crate::prompts::content_reference::PromptContentReference;
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test();
    let context = TemplateContext::default();

    let prompt_ref = PromptContentReference::from_content(
        "Small requirements".to_string(),
        Path::new(".agent/PROMPT.md.backup"),
        "User requirements",
    );

    let result = prompt_planning_xml_with_references(&context, &prompt_ref, &workspace);

    // Should embed content inline
    assert!(result.contains("Small requirements"));
    assert!(result.contains("PLANNING MODE"));

    // Read-only modes: planner must still write exactly one XML file.
    assert!(
        result.contains("explicitly authorized") && result.contains("EXACTLY ONE file"),
        "planning_xml should explicitly authorize writing exactly one XML file"
    );
    assert!(
        result.contains("MANDATORY"),
        "planning_xml should mark XML file write mandatory"
    );
    assert!(
        result.contains("Not writing") && result.contains("FAILURE"),
        "planning_xml should say not writing XML is a failure"
    );
    assert!(
        result.contains("does not conform") && result.contains("XSD") && result.contains("FAILURE"),
        "planning_xml should say non-XSD XML is a failure"
    );
    assert!(
        result.contains("READ-ONLY")
            && (result.contains("EXCEPT FOR writing")
                || result.contains("except for writing")
                || result.contains("Except for writing"))
            && result.contains("plan.xml"),
        "planning_xml should be read-only except for writing plan.xml"
    );

    assert!(
        !result.contains("DO NOT print")
            && !result.contains("Do NOT print")
            && !result.contains("ONLY acceptable output")
            && !result.contains("The ONLY acceptable output"),
        "planning_xml should not include stdout suppression wording"
    );
}

#[test]
fn test_prompt_planning_xml_with_references_large_content() {
    use crate::prompts::content_reference::{PromptContentReference, MAX_INLINE_CONTENT_SIZE};
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test().with_file(".agent/PROMPT.md.backup", "backup");
    let context = TemplateContext::default();
    let large_content = "x".repeat(MAX_INLINE_CONTENT_SIZE + 1);

    let prompt_ref = PromptContentReference::from_content(
        large_content,
        Path::new(".agent/PROMPT.md.backup"),
        "User requirements",
    );

    let result = prompt_planning_xml_with_references(&context, &prompt_ref, &workspace);

    // Should reference backup file, not embed content
    assert!(result.contains("PROMPT.md.backup"));
    assert!(result.contains("Read from"));
    assert!(result.contains("PLANNING MODE"));
}

#[test]
fn test_prompt_planning_xml_with_references_writes_xsd() {
    use crate::prompts::content_reference::PromptContentReference;
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test();
    let context = TemplateContext::default();

    let prompt_ref = PromptContentReference::inline("Test requirements".to_string());

    let _result = prompt_planning_xml_with_references(&context, &prompt_ref, &workspace);

    // Should have written the XSD schema file
    assert!(workspace.exists(Path::new(".agent/tmp/plan.xsd")));
}

#[test]
fn test_prompt_planning_xsd_retry_with_context_has_read_only_overrides() {
    use crate::workspace::MemoryWorkspace;

    let context = TemplateContext::default();
    let workspace = MemoryWorkspace::new_test();

    let result = prompt_planning_xsd_retry_with_context(
        &context,
        "prompt content",
        "XSD error",
        "last output",
        &workspace,
    );

    assert!(result.contains("XSD error"));
    assert!(result.contains(".agent/tmp/plan.xsd"));
    assert!(result.contains(".agent/tmp/last_output.xml"));

    assert!(
        result.contains("explicitly authorized") && result.contains("EXACTLY ONE file"),
        "planning_xsd_retry should explicitly authorize writing exactly one XML file"
    );
    assert!(
        result.contains("MANDATORY"),
        "planning_xsd_retry should mark XML file write mandatory"
    );
    assert!(
        result.contains("Not writing") && result.contains("FAILURE"),
        "planning_xsd_retry should say not writing XML is a failure"
    );
    assert!(
        result.contains("does not conform") && result.contains("XSD") && result.contains("FAILURE"),
        "planning_xsd_retry should say non-XSD XML is a failure"
    );
    assert!(
        result.contains("READ-ONLY")
            && (result.contains("EXCEPT FOR writing")
                || result.contains("except for writing")
                || result.contains("Except for writing"))
            && result.contains("plan.xml"),
        "planning_xsd_retry should be read-only except for writing plan.xml"
    );

    assert!(
        !result.contains("DO NOT print")
            && !result.contains("Do NOT print")
            && !result.contains("ONLY acceptable output")
            && !result.contains("The ONLY acceptable output"),
        "planning_xsd_retry should not include stdout suppression wording"
    );

    // Verify files were written to workspace
    assert!(workspace.was_written(".agent/tmp/plan.xsd"));
    assert!(workspace.was_written(".agent/tmp/last_output.xml"));
}

#[test]
fn test_continuation_prompt_contains_expected_elements() {
    use crate::reducer::state::{ContinuationState, DevelopmentStatus};
    use crate::workspace::MemoryWorkspace;

    let context = TemplateContext::default();
    let continuation_state = ContinuationState::new().trigger_continuation(
        DevelopmentStatus::Partial,
        "Implemented half the feature".to_string(),
        Some(vec!["src/lib.rs".to_string(), "src/main.rs".to_string()]),
        Some("Add tests for the new functionality".to_string()),
    );
    let workspace = MemoryWorkspace::new_test();
    let prompt =
        prompt_developer_iteration_continuation_xml(&context, &continuation_state, &workspace);

    // Debug: print the prompt to see what we're actually getting
    eprintln!("Generated prompt:\n{prompt}");

    // Verify the prompt contains key elements
    assert!(
        prompt.contains("IMPLEMENTATION MODE"),
        "Prompt should match iteration mode framing"
    );
    assert!(
        prompt.contains("CONTINUATION CONTEXT"),
        "Prompt should include minimal continuation context section"
    );
    assert!(
        prompt.contains("partial"),
        "Prompt should include previous status"
    );
    assert!(
        prompt.contains("Implemented half the feature"),
        "Prompt should include previous summary"
    );
    assert!(
        prompt.contains("Add tests for the new functionality"),
        "Prompt should include next steps when provided"
    );
    assert!(
        prompt.contains("failed to fully complete the entire plan")
            || prompt.contains("did not fully complete the entire plan"),
        "Continuation prompt should frame continuation as failure to fully complete the plan"
    );
    assert!(
        prompt.contains(
            "Success in this run means finishing the entire remaining plan to completion"
        ) || prompt.contains("Success means finishing the entire remaining plan to completion"),
        "Continuation prompt should set full plan completion as the default expectation"
    );
    assert!(
        prompt.contains("Going beyond the plan is acceptable")
            || prompt.contains("going beyond the plan is acceptable")
            || prompt.contains("acceptable to do more than the minimum remaining plan work"),
        "Continuation prompt should explicitly allow exceeding the minimum plan when that improves completion"
    );
    assert!(
        prompt.contains("ordered, actionable checklist"),
        "Continuation prompt should require an ordered checklist for recovery work"
    );
    assert!(
        prompt.contains("should resolve the remaining plan when completed"),
        "Continuation prompt should treat the passed checklist as sufficient to resolve the remaining plan"
    );
    assert!(
        prompt.contains("starting point")
            || prompt.contains("not the boundary of the remaining work"),
        "Continuation prompt should treat the passed checklist as a starting point, not a hard boundary"
    );
    assert!(
        prompt
            .to_lowercase()
            .contains("the plan is the goal, not the checklist")
            || prompt
                .to_lowercase()
                .contains("success is completing the plan, not finishing the checklist"),
        "Continuation prompt should explicitly prioritize full-plan completion over checklist completion"
    );
    assert!(
        prompt.contains("do whatever it takes to complete the entire remaining plan")
            || prompt.contains("complete the entire remaining plan by whatever work is required"),
        "Continuation prompt should frame continuation as full-plan completion work, not narrow recovery"
    );
    assert!(
        prompt.contains("ordered, actionable checklist") && prompt.contains("remaining plan"),
        "Continuation prompt should require an ordered actionable checklist for the remaining plan"
    );
    assert!(
        prompt.contains("starting point")
            || prompt.contains("not the boundary of the remaining work"),
        "Continuation prompt should treat prior continuation context as a starting point, not a boundary"
    );
    assert!(
        prompt
            .to_lowercase()
            .contains("use the previous summary and checklist as execution context"),
        "Continuation prompt should frame prior continuation data as execution context, not communication output"
    );
    assert!(
        prompt.contains("Continuation is an exception path")
            || prompt.contains("continuation is an exception path"),
        "Continuation prompt should explicitly frame continuation as exceptional"
    );
    assert!(
        prompt.contains("continuation 1 of"),
        "Prompt should include continuation progress label"
    );
    assert!(
        !prompt.contains("ANALYSIS AGENT ROLE"),
        "Prompt should not describe downstream orchestration"
    );
    assert!(
        prompt.contains("Do NOT create STATUS.md")
            && prompt.contains("CURRENT_STATUS.md")
            && prompt.contains("CURRENT_IMPLEMENTATION.md"),
        "Prompt should explicitly ban status/handoff files"
    );
    assert!(
        prompt.contains("Do NOT write summaries")
            || prompt.contains("Do NOT attempt to communicate"),
        "Prompt should ban summary-style communication"
    );
    assert!(
        !prompt.contains("Files changed in previous attempt:"),
        "Continuation prompt should avoid centering file-list bookkeeping"
    );
    assert!(
        !prompt.contains("src/lib.rs") && !prompt.contains("src/main.rs"),
        "Continuation prompt should not inline previous file lists"
    );
}

#[test]
fn test_continuation_prompt_includes_verification_guidance() {
    use crate::reducer::state::{ContinuationState, DevelopmentStatus};
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test();
    let context = TemplateContext::default();
    let continuation_state = ContinuationState::new().trigger_continuation(
        DevelopmentStatus::Partial,
        "Previous work summary".to_string(),
        None,
        None,
    );

    let prompt =
        prompt_developer_iteration_continuation_xml(&context, &continuation_state, &workspace);

    // Should include new verification section
    assert!(
        prompt.contains("VERIFICATION AND VALIDATION"),
        "Continuation prompt should include verification guidance"
    );
    assert!(
        prompt.contains("build/test commands"),
        "Should mention build/test verification"
    );
    assert!(
        prompt.contains("If the plan specifies verification"),
        "Should mention plan-specified verification"
    );

    // Should include exploration section
    assert!(
        prompt.contains("EXPLORATION AND CONTEXT GATHERING"),
        "Should include exploration guidance"
    );
    assert!(
        prompt.contains("Read files beyond the plan"),
        "Should encourage broader exploration"
    );

    // Should NOT include old progress verification section
    assert!(
        !prompt.contains("You do NOT need to produce structured status output"),
        "Should not contain outdated verification section"
    );
    assert!(
        !prompt.contains("What was accomplished:"),
        "Should avoid broad summary/handoff sections"
    );
}

#[test]
fn test_continuation_prompt_emphasizes_recovery_over_incidental_activity() {
    use crate::reducer::state::{ContinuationState, DevelopmentStatus};
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test();
    let context = TemplateContext::default();
    let continuation_state = ContinuationState::new().trigger_continuation(
        DevelopmentStatus::Failed,
        "Compilation failed after only partially implementing the plan".to_string(),
        Some(vec!["src/lib.rs".to_string(), "src/main.rs".to_string()]),
        Some(
            "1. Fix the compile errors\n2. Finish the remaining tests\n3. Re-run verification"
                .to_string(),
        ),
    );

    let prompt =
        prompt_developer_iteration_continuation_xml(&context, &continuation_state, &workspace);

    assert!(
        prompt.contains("Focus the continuation on completing the entire remaining plan")
            || prompt.contains("do whatever it takes to complete the entire remaining plan"),
        "Continuation prompt should center full-plan completion rather than narrow recovery"
    );
    assert!(
        prompt
            .to_lowercase()
            .contains("use the previous summary and checklist as execution context"),
        "Continuation prompt should frame prior continuation data as execution context, not communication output"
    );
    assert!(
        prompt.contains("remaining non-plan follow-up work discovered during verification")
            || prompt.contains("failed verification commands or checks"),
        "Continuation prompt should preserve the detailed recovery checklist framing from analysis output"
    );
    assert!(
        prompt.contains("starting point")
            || prompt.contains("not the boundary of the remaining work"),
        "Continuation prompt should tell the next run to expand beyond the handed-off checklist when needed"
    );
    assert!(
        prompt
            .to_lowercase()
            .contains("the plan is the goal, not the checklist")
            || prompt
                .to_lowercase()
                .contains("success is completing the plan, not finishing the checklist"),
        "Continuation prompt should explicitly prioritize full-plan completion over checklist completion"
    );
    assert!(
        prompt.contains(
            "actionable and specific enough for the next run to continue without ambiguity"
        ) || (prompt.contains("ordered, actionable checklist")
            && prompt.contains("specific enough for the next run to continue without ambiguity")),
        "Continuation prompt should require an actionable, ambiguity-free remaining-work checklist"
    );
    assert!(
        prompt.contains("remaining work needed to finish the entire plan")
            || prompt.contains("finish the entire remaining plan")
            || prompt.contains("finishing the remaining plan"),
        "Continuation prompt should center the whole remaining plan, not a local next step"
    );
    assert!(
        !prompt.contains(
            "failed to fully complete the plan and failed to fully complete the entire plan"
        ),
        "Continuation prompt should avoid duplicated whole-plan failure wording"
    );
    assert!(
        !prompt.contains(
            "Provide an ordered, actionable checklist for the remaining plan and the remaining work needed to finish the entire plan"
        ),
        "Continuation prompt should avoid repetitive checklist wording"
    );
}

#[test]
fn test_continuation_prompt_includes_original_request_and_plan_sections() {
    use crate::reducer::state::{ContinuationState, DevelopmentStatus};
    use crate::workspace::MemoryWorkspace;
    use std::fs;
    use tempfile::tempdir;

    let workspace = MemoryWorkspace::new_test()
        .with_file("PROMPT.md", "Original request body")
        .with_file(".agent/PLAN.md", "Implementation plan body");
    let context = TemplateContext::default();
    let continuation_state = ContinuationState::new().trigger_continuation(
        DevelopmentStatus::Partial,
        "Previous work summary".to_string(),
        None,
        None,
    );

    let prompt =
        prompt_developer_iteration_continuation_xml(&context, &continuation_state, &workspace);

    assert!(
        prompt.contains("ORIGINAL REQUEST"),
        "Continuation prompt should include ORIGINAL REQUEST section"
    );
    assert!(
        prompt.contains("IMPLEMENTATION PLAN"),
        "Continuation prompt should include IMPLEMENTATION PLAN section"
    );
    assert!(
        prompt.contains("Original request body"),
        "Continuation prompt should include prompt content"
    );
    assert!(
        prompt.contains("Implementation plan body"),
        "Continuation prompt should include plan content"
    );

    let template_dir = tempdir().expect("create temp template dir");
    fs::write(
        template_dir
            .path()
            .join("developer_iteration_continuation_xml.txt"),
        "broken {{MISSING_VARIABLE}} template",
    )
    .expect("write broken continuation template");

    let context = TemplateContext::from_user_templates_dir(Some(template_dir.path().to_path_buf()));
    let continuation_state = ContinuationState::new().trigger_continuation(
        DevelopmentStatus::Partial,
        "Previous work summary".to_string(),
        None,
        Some("1. Finish the remaining work".to_string()),
    );
    let workspace = MemoryWorkspace::new_test()
        .with_file("PROMPT.md", "Original request body")
        .with_file(".agent/PLAN.md", "Implementation plan body");

    let fallback_prompt =
        prompt_developer_iteration_continuation_xml(&context, &continuation_state, &workspace);

    assert!(
        fallback_prompt.contains("ORIGINAL REQUEST"),
        "Fallback continuation prompt should include ORIGINAL REQUEST section"
    );
    assert!(
        fallback_prompt.contains("IMPLEMENTATION PLAN"),
        "Fallback continuation prompt should include IMPLEMENTATION PLAN section"
    );
    assert!(
        fallback_prompt.contains("Original request body"),
        "Fallback continuation prompt should preserve prompt content"
    );
    assert!(
        fallback_prompt.contains("Implementation plan body"),
        "Fallback continuation prompt should preserve plan content"
    );
    assert!(
        fallback_prompt.contains("Success means finishing the entire remaining plan to completion")
            || fallback_prompt.contains(
                "Success in this run means finishing the entire remaining plan to completion"
            ),
        "Fallback continuation prompt should preserve whole-plan completion framing"
    );
    assert!(
        fallback_prompt.contains("1. Finish the remaining work"),
        "Fallback continuation prompt should preserve the ordered recovery checklist when provided"
    );
    assert!(
        fallback_prompt.contains("VERIFICATION AND VALIDATION")
            && fallback_prompt.contains("EXPLORATION AND CONTEXT GATHERING"),
        "Fallback continuation prompt should preserve shared developer iteration guidance"
    );
    assert!(
        fallback_prompt.contains("Do NOT run ANY git command except read-only lookup commands"),
        "Fallback continuation prompt should preserve read-only git guidance"
    );
    assert!(
        !fallback_prompt.contains(
            "failed to fully complete the plan and failed to fully complete the entire plan"
        ),
        "Fallback continuation prompt should avoid duplicated whole-plan failure wording"
    );
    assert!(
        !fallback_prompt.contains(
            "Provide an ordered, actionable checklist for the remaining plan and the remaining work needed to finish the entire plan"
        ),
        "Fallback continuation prompt should avoid repetitive checklist wording"
    );

    let true_fallback_prompt = fallback_continuation_prompt(
        2,
        "failed",
        "The full plan was not completed because verification still fails.",
        Some(
            "1. Fix the failing verification.\n2. Re-run the focused continuation tests.\n3. Finish the remaining plan and run repository verification.",
        ),
        "Original request body",
        "Implementation plan body",
    );

    assert!(
        true_fallback_prompt.contains("UNATTENDED MODE")
            && true_fallback_prompt
                .contains("Do NOT run ANY git command except read-only lookup commands"),
        "True string fallback should preserve unattended and read-only git guidance"
    );
    assert!(
        true_fallback_prompt.contains("VERIFICATION AND VALIDATION")
            && true_fallback_prompt.contains("EXPLORATION AND CONTEXT GATHERING"),
        "True string fallback should preserve shared developer iteration guidance"
    );
    assert!(
        true_fallback_prompt.contains("ORIGINAL REQUEST")
            && true_fallback_prompt.contains("IMPLEMENTATION PLAN")
            && true_fallback_prompt.contains("Original request body")
            && true_fallback_prompt.contains("Implementation plan body"),
        "True string fallback should preserve original request and plan context"
    );
}

#[test]
fn test_initial_iteration_prompt_includes_verification_guidance() {
    use crate::workspace::MemoryWorkspace;

    let workspace = MemoryWorkspace::new_test()
        .with_file("PROMPT.md", "Test prompt")
        .with_file(".agent/PLAN.md", "Test plan");
    let context = TemplateContext::default();

    let prompt = prompt_developer_iteration_xml_with_context(
        &context,
        "test prompt",
        "test plan",
        &workspace,
    );

    // Should include verification section
    assert!(
        prompt.contains("VERIFICATION AND VALIDATION"),
        "Initial iteration prompt should include verification guidance"
    );

    // Should include exploration section
    assert!(
        prompt.contains("EXPLORATION AND CONTEXT GATHERING"),
        "Should include exploration guidance"
    );

    // Should NOT include old progress verification wording
    assert!(
        !prompt.contains("You do NOT need to produce structured status output"),
        "Should not contain outdated verification section"
    );
}