Motility coupled to responsive behavior is essential for many microorganisms to seek and establish appropriate habitats. One of the simplest possible responses, reversing the direction of motion, is believed to enable filamentous cyanobacteria to form stable aggregates or accumulate in suitable light conditions. Here, we demonstrate that filamentous morphology in combination with responding to light gradients by reversals has consequences far beyond simple accumulation: Entangled aggregates form at the boundaries of illuminated regions, harnessing the boundary to establish local order. We explore how the light pattern, in particular its boundary curvature, impacts aggregation. A minimal mechanistic model of active flexible filaments resembles the experimental findings, thereby revealing the emergent and generic character of these structures. This phenomenon may enable elongated microorganisms to generate adaptive colony architectures in limited habitats or guide the assembly of biomimetic fibrous materials.