Situation: Paula the Paladin and her friend Severus the Sorcerer are fighting a monster. Severus casts cloud of daggers (PHB, p. 222) in front of (but not in contact with) the monster:
You fill the air with spinning daggers in a cube 5 feet on each side, centered on a point you choose within range. A creature takes 4d4 slashing damage when it enters the spell's area for the first time on a turn or starts its turn there.
Then it's Paula's turn. She stands behind the cloud of daggers and casts compelled duel, which says in part (PHB, p. 224):
The spell ends if you attack any other creature, if you cast a spell that targets a hostile creature other than the target, if a creature friendly to you damages the target or casts a harmful spell on it, or if you end your turn more than 30 feet away from the target.
The monster then runs through the cloud of daggers and takes damage.1 Does compelled duel end?
The "casts a harmful spell" condition is almost surely not relevant; Severus cast the spell before Paula cast compelled duel, and he didn't cast it on the monster, but on an area adjacent to the monster. I'm much less sure about the "damages the target" condition.
On the one hand, he cast a damaging spell which then damaged the monster. Usually we'd consider that doing damage to it, even if the monster is only hit by being in an area of effect.
On the other hand, Severus didn't do anything. He had previously created a cloud of daggers somewhere in the room. The immediate cause of the damage is the daggers; the proximate cause is the monster's decision to run through the cloud.
(This question focuses on cloud of daggers because that's what happened at the table. I assume the logic would be the same for any spell that has a non-instant duration and creates a damaging area of effect (cloudkill, moonbeam, wall of fire, etc.); if not, an explanation of why not would be welcome.)
1 Severus is aware that compelled duel doesn't force the monster to mindlessly charge at its designated target, but he's betting on the monster being stupid enough to do that; possibly there isn't any other route to get to Paula.