Recently, I played a warlock in a 5e one-shot. We were playing at level 7 and I was a Pact of the Blade warlock with the Fiend patron. As a Fiend Warlock, I have a feature called "Dark One's Blessing", :
Starting at 1st level, when you reduce a hostile creature to 0 hit points, you gain temporary hit points equal to your Charisma modifier + your warlock level (minimum of 1).
The description of the Armor of Agathys spell reads:
A protective magical force surrounds you, manifesting as a spectral frost that covers you and your gear. You gain 5 temporary hit points for the duration. If a creature hits you with a melee attack while you have these hit points, the creature takes 5 cold damage.
At Higher Levels. When you cast this spell using a spell slot o f 2nd level or higher, both the temporary hit points and the cold damage increase by 5 for each slot level above 1st.
The situation was that there was a pack of 'minions' (4th-edition term, I know... but they were low-AC 5 hp monsters that died in 1 hit most of the time) attacking my group. The dragonborn wizard knew Fly, and grabbed the halfling and flew out of reach of the group of minions; I was left there with Armor of Agathys cast on me at level 4, so I had 20 temp hp and did 20 damage to each minion.
The question comes from the functionality of Temp HP (THP)... It does not stack. Instead, you must choose which set to acquire, either keeping the THP you currently have or using the new number provided by whatever is trying to give you more THP.
Once I was below 20 THP from the attacks made on me by this swarm of minions, I started taking the 10 (warlock level + CHA mod= 7+3) THP provided by Dark One's Blessing. After rereading Armor of Agathys today, I noted it says 'while you have these hit points'... leading me to believe that choosing to take the 10THP from Dark One's Blessing would remove the Armor of Agathys and its damaging capability.
TL;DR
Does Armor of Agathys only work if you have THP from the spell specifically, or does it still work if you gain more THP from another source (like from Dark One's Blessing) while the spell is still active?