Nonconsumptive effects (NCE) of parasites on hosts vary with habitat complexity thereby modifying trait-mediated effects on lower trophic levels. In coffee agroecosystems, Pseudacteon sp. phorid fly parasites negatively affect Azteca instabilis F. Smith ants via NCE thereby indirectly benefiting prey. It is unknown how differences in habitat complexity influence Azteca-phorid interactions or how phorids affect the coffee berry borer (Hypothenemus hampei Ferrari), an important pest of coffee (Coffea arabica L). We tested the following hypotheses in field and lab experiments to find the impact of NCE of phorids on A. instabilis and trait-mediated indirect effects of phorids on the coffee berry borer: (1) Phorid effects on A. instabilis differ between complex and simple shade habitats and (2) Phorids, by modifying A. instabilis behavior, indirectly affect coffee berry borer abilities to invade coffee berries. Phorids had greater impacts on A. instabilis activity in low-shade farms, but differences in phorid impacts were not mediated by phorid density or light availability. In the lab, phorids had strong cascading effects on abilities of A. instabilis to deter coffee berry borers. Without phorids, A. instabilis limited coffee berry borer attacks, whereas when the coffee berry borer was alone or with A. instabilis and phorids, more coffee fruits were attacked by coffee berry borer. These results indicate that A. instabilis has stronger biological control potential in highshade farms, but the exact mechanism deserves further attention.