The integration of an ingestible dosage form with sensing, actuation and drug delivery capabilities can enable a broad range of surgical-free diagnostic and treatment strategies. However, the gastrointestinal (GI) tract is a highly constrained and complex luminal construct that fundamentally limits the size of an ingestible system. Recent advancements in mesoscale magnetic crawlers have demonstrated the ability to effectively traverse complex and confined systems by leveraging magnetic fields to induce contraction and bending-based locomotion. However, the integration of functional components (e.g., electronics) in the proposed ingestible system remains fundamentally challenging. Here, we demonstrate the creation of a centralized compartment in a magnetic robot by imparting localized flexibility (MR-LF). The centralized compartment enables MR-LF to be readily integrated with modular functional components and payloads, such as commercial off-the-shelf electronics and medication, while preserving its bidirectionality in an ingestible form factor. We demonstrate the ability of MR-LF to incorporate electronics, perform drug delivery, guide continuum devices such as catheters, and navigate air-water environments in confined lumens. The MR-LF enables functional integration to create a highly-integrated ingestible system that can ultimately address a broad range of unmet clinical needs. Keywords: Ingestible electronics; ingestible robots; soft robots; magnetic robots; magnetic crawlers; drug delivery. Corresponding author email: [email protected]