The sophistication, complexity and intelligence of biological systems is a continuous source of inspiration for mankind. Mimicking the natural intelligence to devise tiny systems that are capable of self-regulated, autonomous action to, for example, distinguish different targets, remains among the grand challenges in biomimetic micro-robotics. Herein, we demonstrate an autonomous soft device, a light-driven flytrap, that uses optical feedback to trigger photomechanical actuation. The design is based on light-responsive liquid-crystal elastomer, fabricated onto the tip of an optical fibre, which acts as a power source and serves as a contactless probe that senses the environment. Mimicking natural flytraps, this artificial flytrap is capable of autonomous closure and object recognition. It enables self-regulated actuation within the fibre-sized architecture, thus opening up avenues towards soft, autonomous small-scale devices.