Does Blue Ahri have to use her ability when attacking or defending?

Yes, Ahri, Inquisitive's ability is mandatory when she attacks or defends.

According to the card text, her ability triggers "When I attack or defend." Because the ability does not contain the word "may," it is a mandatory triggered ability.

However, there are two important nuances regarding how this ability functions:

  1. Targeting and Deflect: Ahri, Inquisitive's ability requires you to choose an enemy unit to receive the -2 might. Because it requires a specific choice, it is considered a targeting ability. If the enemy unit you choose has the Deflect keyword, you are required to pay the Deflect cost to apply the effect.
  2. Choosing Not to Pay: While the ability itself is mandatory, if you target a unit with Deflect, you can choose not to pay the Deflect cost. If you choose not to pay (or are unable to pay because you have no runes to recycle), the ability will not resolve on that target.

In summary, the ability must trigger, and you must attempt to resolve it by choosing a target, but if that target has Deflect, you have the option to decline paying the Deflect cost, which prevents the effect from applying to that unit.