That would probably depend upon who the publisher was since the best of them pay advances and have legit distribution. I can see an agent coming on board on sale, at least a major one and taking over the contract at the writer's request. I don't see, however, an agent signing a writer who might have landed a deal and signed the contract without any agent intervention.
This is essentially how it happened for me. There were two publishers I met at a conference who were taking my book to their pub board. One of them (kindly) suggested I should get an agent (it wasn't a standard thing my genre at the time). Within a month I had an offer from one of the publishers, so when I contacted an agent about representation, I could tell them I had an offer on the table. The agent took over at that point--before I signed the contract.
It's not unheard of though, for an agent to take on a new client who has been traditionally published with a respected publisher--or who has already signed a contract. Whether the agent negotiated the contract or not, they will still get their 15% (there is often still much work for them to do on behalf of the author).
I don't think having an e-book contract or small pub credit will necessarily get an agent's attention, but if they resonate with the writer's work and see potential with future projects, I think that gets more consideration than someone who is completely unpublished.
PS--I guess my answer to the OP's original question would be 3. I took my project to a conference and showed it to 4 publishing representatives. 2 declined at the conference, 2 took it to their pub board, one declined and one published it.