If you are getting an LB1, your fuel trims are a given. It's not a question, it's a given.
First stop is pulling the EGR tube. Don't waste the carb cleaner on it. You can't typically get any reaction from it, yet it can leak. Pull back the retainer piece that sits at the LIM and hold the tube to the light. Got a crack? Most do. I have one I'm going to get pictures of very soon. Just got it this weekend on a cam swap car. These tubes are such and issue, I stock up from a JY on them.
Second stop, It's not the O2, the O2 is what reads the condition and tells the pcm about the lean issue. It might be a maf issue, never seen an O2 cause this code though. Because if the O2 fails, there are other codes that will get tossed.
Battery cables. If they are corroded, dirty etc.. this can cause it.
TB gasket.
For more on this fun and exciting code that can plague you for months, search on P0171 and my name.
I bought a ton of stock in this code.