Micro/nanorobots (MNRs) are envisioned to provide revolutionary changes to therapies for infectious diseases as they can deliver various antibacterial agents or energies to many hard-to-reach infection sites. However, existing MNRs face substantial challenges in addressing complex infections that progress from superficial to deep tissues. Here, we develop swarming magnetic Fe3O4@polydopamine-tannic acid nanorobots (Fe3O4@PDA-TA NRs) capable of performing targeted bacteria elimination in complicated bacterial infections by integrating superficial photothermal and deep chemical strategies. The Fe3O4@PDA-TA nanoparticles (NPs), serving as building blocks of the nanorobots, are fabricated by insitu polymerization of dopamine followed by TA adhesion. When driven by alternating magnetic fields, Fe3O4@PDA-TA NPs can assemble into large energetic microswarms continuously flowing forward with tunable velocity. Thus, the swarming Fe3O4@PDA-TA NRs can be navigated to achieve rapid broad coverage of a targeted superficial area from a distance and rapidly eradicate bacteria residing there upon exposure to near-infrared (NIR) light due to their efficient photothermal conversion. Additionally, they can concentrate at deep infection sites by traversing through confined, narrow, and tortuous passages, exerting sustained antibacterial action through their surface TA-induced easy cell adhesion and subsequent membrane destruction. Therefore, the swarming Fe3O4@PDA-TA NRs show great potential for addressing complex superficial-to-deep infections. This study may inspire the development of future therapeutic microsystems for various diseases with multifunction synergies, task flexibility, and high efficiency.