You may be considered a U.S. resident for tax purposes if you are present in the United States for at least 31 days in the current year and reach 183 weighted days over the current year and the previous two years. Count all days in the current year, 1/3 of days in the previous year, and 1/6 of days in the second previous year. Certain days may be excluded under IRS rules.
https://www.irs.gov/individuals/international-taxpayers/substantial-presence-test