@@ -302,6 +302,25 @@ def test_heal_json_balances_open_containers(self, mock_hass):
302302 assert isinstance (parsed ["events" ], list )
303303 assert parsed ["events" ][0 ]["name" ] == "door"
304304
305+ def test_heal_json_concatenated_json_objects (self , mock_hass ):
306+ """Test heal_json keeps the first JSON object from a concatenated stream."""
307+ with patch ("custom_components.llmvision.providers.async_get_clientsession" ):
308+ request = Request (mock_hass , "test" , 1000 , 0.5 )
309+
310+ broken = (
311+ '{"title": "Person at front door", "description": "A person stands on the porch."}'
312+ '{"title": "No activity", "description": "The scene shows an empty driveway and patio with no notable objects."}'
313+ '{"title": "Delivery", "description": "A delivery person is seen standing near the entrance."}'
314+ '{"title": "Person in garden", "description": "Two people stand at the front door."}'
315+ '{"title": "No activity", "description": "The'
316+ )
317+
318+ healed = request .heal_json (broken )
319+ parsed = json .loads (healed )
320+
321+ assert parsed ["title" ] == "Person at front door"
322+ assert parsed ["description" ] == "A person stands on the porch."
323+
305324 def test_heal_json_non_string (self , mock_hass ):
306325 """Test heal_json with non-string input."""
307326 with patch ("custom_components.llmvision.providers.async_get_clientsession" ):
0 commit comments