I had a similar problem with our 02 RX 300. It turned out to be a faulty/bad gas cap and I found the hose that attaches to the air filter box off. When I reattached it and got a new gas cap ($7) the car ran fine. I had to get Auto Zone to clear the codes.
However, this might not be your problem. Your system is running too lean for some reason. Before I took it to a mechanic I would check all the hoses to make sure that one has not come unattached or maybe has a split in it. I recently had the Check Engine Light come on on my Ford Sport Trac and it read "Too Lean". After looking it over real good I found the hose that ran to the PCV Valve had a split in it. Replaced the hose, $2, and it cleared the light and runs fine.
You might have an 02 Sensor problem but this forum is full of threads where owners get the P0171 reading and it is not the sensor but something minor that sets the light off.
Good Luck