@@ -174,3 +174,57 @@ def test_food_truck_open_kitchen_predicate_uses_json_field_not_substring():
174174 section = prompt [idx : idx + 500 ]
175175 assert "--- INGREDIENTS TABLE ---" not in section
176176 assert "ingredients_table" in section
177+
178+
179+ def test_food_truck_prompt_has_degraded_response_halt_rule ():
180+ prompt = _build_food_truck_prompt (
181+ recipe = "test-recipe" ,
182+ task = "Test task" ,
183+ ingredients = {},
184+ mcp_prefix = DIRECT_PREFIX ,
185+ dispatch_id = "test-dispatch" ,
186+ campaign_id = "test-campaign" ,
187+ l3_timeout_sec = 300 ,
188+ )
189+ assert "FAILURE PREDICATE — DEGRADED RESPONSE" in prompt
190+ assert 'reason="degraded_tool_response"' in prompt
191+
192+
193+ def test_food_truck_prompt_degraded_rule_triggers_sentinel_on_empty_content ():
194+ prompt = _build_food_truck_prompt (
195+ recipe = "test-recipe" ,
196+ task = "Test task" ,
197+ ingredients = {},
198+ mcp_prefix = DIRECT_PREFIX ,
199+ dispatch_id = "test-dispatch" ,
200+ campaign_id = "test-campaign" ,
201+ l3_timeout_sec = 300 ,
202+ )
203+ start = prompt .index ("FAILURE PREDICATE — DEGRADED RESPONSE" )
204+ end = prompt .index ("TWO FAILURE TIERS" , start )
205+ section = prompt [start :end ]
206+ assert "success" in section
207+ assert "false" in section
208+ assert any (word in section for word in ("absent" , "null" , "empty" )), (
209+ "Rule must reference absent, null, or empty content"
210+ )
211+
212+
213+ def test_food_truck_prompt_degraded_reason_in_reason_enum ():
214+ prompt = _build_food_truck_prompt (
215+ recipe = "test-recipe" ,
216+ task = "Test task" ,
217+ ingredients = {},
218+ mcp_prefix = DIRECT_PREFIX ,
219+ dispatch_id = "test-dispatch" ,
220+ campaign_id = "test-campaign" ,
221+ l3_timeout_sec = 300 ,
222+ )
223+ fields_idx = prompt .index ("Fields:" , prompt .index ("--- SECTION 8:" ))
224+ reason_region = prompt [fields_idx : fields_idx + 300 ]
225+ assert "degraded_tool_response" in reason_region , (
226+ "degraded_tool_response must appear in Section 8 reason enum"
227+ )
228+ ok_idx = prompt .index ("FAILURE PREDICATE — open_kitchen" )
229+ deg_idx = prompt .index ("FAILURE PREDICATE — DEGRADED RESPONSE" )
230+ assert ok_idx != deg_idx , "Degraded and open_kitchen predicates must be distinct blocks"
0 commit comments