Bees foraging for nectar often have to discriminate between flowers with similar appearance but different nectar rewards. At the same time, they must be vigilant for ambush predators, such as crab spiders, which can camouflage themselves on flowers. We investigated whether bees, Bombus terrestris, can efficiently discriminate similar flower colours while exposed to predation threat from cryptic predators. Bees were individually tested in tightly controlled laboratory experiments using artificial flowers whose nectar supply was administered with precision pumps. Predation risk was simulated by automated crab spider 'robots' that captured bees for a limited duration without injuring them. Bees' behaviour was monitored by a 3D video tracking system. We experimented with both cryptic and conspicuous spiders, finding that bees had no difficulty avoiding conspicuous spiders while still foraging adaptively. Conversely, they prioritized predator avoidance at the expense of maximizing energy intake when faced with detecting cryptic predators and a difficult colour discrimination task. This difference in behaviour was not due to cognitive limitations: bees were able to discriminate between similar flower types under predation risk from cryptic spiders when choosing the safe flower type incurred a gustatory punishment in the form of bitter quinine solution. However, this resulted in bees incurring substantially higher costs in terms of floral inspection times. We conclude that bees have the capacity to attend to difficult foraging tasks while simultaneously avoiding cryptic predators, but only do so when avoidance of gustatory punishment justifies the increased costs.