AI perception swapping teams at runtime?

The AI perception component has its own tick interval so I would suggest to avoid getting the perceived actors in each tick and use the OnPerceivedActors function that is provided with the component itself. From what you’re describing it seems like you may be able to get away using a simple flag:

For example you can have a boolean property (maybe named bHasDoneSomethingIllegal which will be true in the end of certain actions) and your AI is perceiving an actor that has set the aforementioned flag to true can be considered as hostile. Although using this approach would require to check all the perceived actors instead of just the hostile ones.