def test_process_streaming_content_incremental_progressive_list_building():
    """Test progressive list building with incremental updates."""
    # Start with empty show
    current_show = Show(title="Comedy Show", jokes=[])

    # First update - add one joke
    response1 = ChatResponse(
        message=ChatMessage(
            role=MessageRole.ASSISTANT,
            content='{"title": "Comedy Show", "jokes": [{"setup": "First joke", "punchline": "First punchline"}]}',
        )
    )

    result1 = process_streaming_content_incremental(response1, Show, current_show)
    assert len(result1.jokes) == 1
    assert result1.jokes[0].setup == "First joke"

    # Second update - add another joke
    response2 = ChatResponse(
        message=ChatMessage(
            role=MessageRole.ASSISTANT,
            content='{"title": "Comedy Show", "jokes": [{"setup": "First joke", "punchline": "First punchline"}, {"setup": "Second joke", "punchline": "Second punchline"}]}',
        )
    )

    result2 = process_streaming_content_incremental(response2, Show, result1)
    assert len(result2.jokes) == 2
    assert result2.jokes[1].setup == "Second joke"
Test progressive list building with incremental updates.
llama-index-core/tests/program/test_streaming_utils.py