This isn’t an answer anyone is going to like, but it’s the truth: only the author knows when the book is ready to submit.
I will say this, don’t ever send a query on a first draft. You should revise at least once (ideally a couple times) before you start submitting. Remember, this is likely your only chance with that agent for this project, and you want to make sure you’re achieving the best first impression you can. If your book is full of grammar and spelling errors, disorganized, has extensive plot holes, and generally reads like a first draft, you’re going to ruin your chance with an agent.
My recommendation is always to set your book aside for a couple of months after you finish it. Start working on something else, give yourself a break, start creating your submission list, do anything else you want in that time, but do not touch that manuscript. Then, come back to it with fresh eyes and start revising. That distance will help immensely, I promise.
You can also have others take a look at the manuscript. Writing groups and critique partners are great for getting an extra set of eyes on your work. Of course, take their feedback with a grain of salt. Make sure you’re staying true to your vision for the story. You want to take the feedback that will enhance your book, but remember it is your book.
Basically, you should go as far with the manuscript as you can go before you have submitted it. Once you reach the point where you feel like you have done what you can and it’s ready, then you can start submitting your work. Like I said, only the author knows when that point is reached.
If you like what I talk about on my blog, consider buying me a coffee: https://ko-fi.com/tiarosemele