When an invading insect threatens an ant colony' s territory or food sources, the ants will vigorously swarm over the invader, biting or stinging it  This defensive tactic can effectively deter even aggressive flying insects, such as wasps  Ants do not attack all insects within their territory, however  For example, riodinid caterpillars commonly live harmoniously among South American ants
These caterpillars, which are a favorite prey of wasps, produce secretions the ants consume as food
The secretions produced by riodinid caterpillars are chemically identical to substances secreted by plants on which South American ants also feed.