Roy is absolutely right you probably have a vacuum leak on the passenger side bank of the engine or the O2 sensor may be failing and giving a false signal indicating a lean running condition. Many automotive repair shops have a machine that generates an inert non flammable low pressure smoke that looks similar to cigar smoke. The intake manifold is sealed off, and smoke is put into the engines intake manifold. The smoke then fills the engines crankcase and if there are any vacuum leaks from gaskets, hoses, or housing smoke emits from the source of the leak. Some mechanics will use propane or aerosol carburetor cleaner, with the engine running they will spray the cleaner or propane around the intake manifold and vacuum hoses. A leak will cause a "lean mixture" condition, when the flammable fuel (carburetor cleaner or propane) comes in contact with the source of the vacuum leak the engine idle speed will raise as the engine has received "fuel". this method of finding a vacuum leak works but is not recommended as it can easily cause a fire.
bank 1 is the passenger side,look at the o2 sensor data with a scan tool to make sure that the sensor will switch when you spray some throttle body cleaner in a vacuum line.also check for a vacuum leak at the pcv tube fitting at the back of the throttle body.but like my comrades were saying,p0171 usually is not an o2 sensor problem.have had numerous part store misdiagnosis customers from this,just to find out that a vacuum leak was the culprit,not the 100 dollar sensor.
Had the same error code on a 2004 ford expedition and it was the bank 1 O2 sensor located under the car just in front of the cat converter on the passanger side exhaust line. Once the o2 sensor was replaced the truck ran great and add some fuel injection cleaner the truck is running like a champ.