Jeff is right- you asked a great question. It is a great question because in Illinois (and I'd argue nationally) Realtors have done a very poor job of describing to the general public what "agency" consists of, and in Illinois "procuring cause" has too often been reduced to simply who showed you the property first.
The short answer to your question is yes. However it is possible and probable that the agent that you think should be compensated for representing you will not be unless the two agents in question come to a written agreement regarding compensation before your offer is submitted/accepted on the foreclosure property.
For all intents and purposes it is not really your responsibility to assist the agents in question in reaching an agreement. However I'd strongly suggest telling the agent that you would prefer to work with about the other agent. You should also provide the agent of your preference the contact information to the other agent. The agents should be able to reach an commission or referral agreement that is acceptable to both of them (and which as a practical matter really does not require your participation or agreement) as long as they realize that there is a potential disputed commission if they fail to do so.
I'd suggest doing this sooner rather than later so that your opportunity to purchase the foreclosure that you're interested in is not hamstrung by waiting and possibly having someone else submit an accepted offer on the property before you get an opportunity to do so. You may also want to inform the listing agent (the seller's agent) which agent of yours they should be communicating with in the future.
Once the two agents in question have reached an agreement, then you might want to sign a buyer's brokerage agreement with the agent whom you'd prefer to work with. This document will strengthen your agent's case if/when there is ever any dispute over the commission earned.
I think that most buyer's agents in Illinois do not use Buyer's Brokerage agreements because it is not considered "common practice" in this state and they don't want to scare off buyers. However as Jeff correctly states in his post "most good buyer agents require a written agreement, just like a listing agent would if you are selling a home." The exact scenario you describe is just the most obvious example of why buyer's agents should present their buyers with a Buyer's Brokerage agreement.
I hope to see more buyer's agents using the contracts that they are supposed to use when working with their buyers in the very near future. In addition to protecting the agents, the brokerage agreement requires the buyer's agents to describe to you (in more detail than most do traditionally) what exactly they will be doing for you during your sales process. And feel free to contact the Chicago Association of Realtors at 312-803-4900 if you have additional questions. Good luck.
Broker Associate, Sudler Sotheby's International Realty
If the agent who showed the property is NOT the listing agent, then the procuring cause was that agent and they are technically due the commission if you decide to purchase that piece of property. If the agent who showed you the property is the listing agent, then it shouldn't be a problem working with the agent you like because you do not have to agree to dual agency.
In the future you (and other buyers) can avoid this type of sticky situation by having an agreement in place with an agent you trust and like and when you contact other agents when you are searching on your own, make sure the first thing that comes out of your mouth is that you are represented by a buyers agent.
The procurring cause statement is a tricky one. You owe the agent that follows through with you to culminate a sale, a commission. However, you as a buyer have the right to fire an agent that you feel is not working in your best interest.
So, the answer is yes, you can fire your current agent, and go back to the original one. But the question comes into play, why did you ever leave them in the first place?