Generally you're free to do whatever you wish with your free time outside working hours and the employment contract has no power over it.
Guessing it's not illegal to solicit someone under such a contract, but potentially a new hire could be ordered by a court to stop working at the new company, or a 3rd party could make claims that the outputs of their former employees are owned by said 3rd party.
IANAL
I would expect my company to be unhappy if I were to consult for a competitor on the side. There's probably language in the employment agreement that prohibits that, and even if there isn't, it's still the kind of thing you should avoid due to conflict of interest.
But I'm not sure about an agreement not to take a similar role. If the employment agreement says that, I'm not sure that it's legally binding. Even if it is, you may be able to weasel around it with "but it's consulting, not a full-time position".
Note well: IANAL. If you're concerned, get advice from a lawyer rather than from some rando on the internet.