An embodiment of an ingestible device for the delivery of a therapeutic agent includes a swallowable outer shell and a delivery mechanism within the outer shell. The delivery mechanism includes an expandable enclosure. The delivery mechanism is triggerable in situ within a gastrointestinal (GI) tract of a body to expand multiple regions of the expandable enclosure to an expanded state at a delivery location within the body. The multiple regions include a head region and a tail region with a protective recess defined between the head region and the tail region, and a retention region within the protective recess. A dimension of the retention region as expanded is less than a dimension of the head region as expanded and less than a dimension of the tail region as expanded. The ingestible device includes a shaped composition disposed at the retention region.