diff --git a/test/core/test_astream_incremental.py b/test/core/test_astream_incremental.py index 3da4f2ede..ea8c08f5e 100644 --- a/test/core/test_astream_incremental.py +++ b/test/core/test_astream_incremental.py @@ -40,14 +40,7 @@ async def test_astream_returns_incremental_chunks(): # If not computed, chunk2 should be new content only assert chunk2 is not None, "Second chunk should not be None if not computed" - # The key test: chunk2 should NOT start with chunk1 - # (it should be incremental, not accumulated) if len(chunk2) > 0: - # chunk2 should be different from chunk1 (new content) - assert chunk2 != chunk1, ( - "Second chunk should be different from first (incremental)" - ) - # Get final value final_val = await mot.avalue() @@ -133,13 +126,14 @@ async def test_astream_beginning_length_tracking(): # Second call: beginning_length should be captured at start of this call chunk2 = await mot.astream() - if chunk2 and len(chunk2) > 0: - # chunk2 should not include chunk1's content - # This verifies the slicing logic at lines 352-356 - if chunk1: - assert not chunk2.startswith(chunk1), ( - "Second chunk should not start with first chunk (should be incremental)" - ) + if chunk2 and len(chunk2) > 0 and chunk1: + # Verify that chunks reassemble correctly (not that they differ textually — + # two consecutive identical tokens are valid). + final_val = await mot.avalue() + accumulated = chunk1 + chunk2 + assert final_val.startswith(accumulated) or accumulated.startswith(final_val), ( + "Assembled chunks should match final value progression" + ) @pytest.mark.ollama