def test_process_streaming_content_incremental_validation_error_fallback():
    """Test fallback when validation to target class fails."""
    # Create content that validates to FlexibleModel but not to strict Person
    response = ChatResponse(
        message=ChatMessage(
            role=MessageRole.ASSISTANT,
            content='{"name": "John", "unknown_field": "value"}',
        )
    )

    result = process_streaming_content_incremental(response, Person)
    # Should return the flexible model instance when strict validation fails
    assert hasattr(result, "name")
    # Should still have the name field
    if hasattr(result, "name"):
        assert result.name == "John"
Test fallback when validation to target class fails.
llama-index-core/tests/program/test_streaming_utils.py