My son is older (11), and I don't keep him away from any children, anymore. He is an extremely empathetic kiddo, and we talk a lot about why friends (both children and adults) act in certain ways or say certain things. That said, he will not tolerate people treating him badly consistently. He will choose not to be around these people.
But, one of the reasons he's able to advocate for himself in this way is that I used to limit the people I surrounded him with. There are toxic people in the world - both adults and children. I don't bring toxic adults into my home. Why would I allow toxic children to stress us out or hurt us?
Yes, I sometimes kept him away from other children. There have been several children on our street that I did not feel comfortable allowing to play with my kiddo - kids who pulled my child in directions neither he nor I felt comfortable with. But, because he was such a social kiddo, and because our street has few kids his age, he was hard pressed to tell them he didn't want to play. So, I had to do it for him.
It caused some stress for a little while. He desperately wanted to play with these kids who called him names, tied him up, hit him with sticks and rocks.... But, it also gave us a chance to discuss why people act the way they do and how we expect to be treated. And, I believe that's why he's able to advocate for himself today - lots of discussions about empathy and making sure he was surrounded by people who treated him with respect and kindness.
We spend a lot of time with a group of homeschooled kids we've known for over four years. There are kids in this group I'm not overjoyed to see, but I don't prohibit my son from spending time with them. The neighborhood kids were an extreme case. These kids aren't. My son will play with them as long as he's enjoying himself, but if he feels like he's being bullied or taken advantage of, he will state his problem with the situation and walk away.

I can't even begin to tell you how proud I am of that. (I worried that, because he was going back to the abusive kids in the neighborhood again and again - before I put a stop to it - that he would allow himself to be subjected to that kind of treatment throughout his life.)
So, I will advocate for my child. And, on occasion, I will advocate for him against his wishes; I can see things in people and in situations that he can't yet see. Most of the time, however, I will simply be there to talk him through any problems he's having with people/relationships. I would never dream of keeping him away from all children or from all children I don't particularly like. It's through experiences with people of all sorts that he will develop the empathy to understand others and the strength to advocate for himself.
Follow Mothering