This sentence is like this: "The agency was too clever, but it cost Qing Qing's life."
The phrase "Dream of Red Mansions" is used to describe Wang Xifeng, which means that she is smart. Instead, he was fooled by his cleverness and used all possible means to get rid of all the traps. In the end, he killed himself. So it refers to Wang Xifeng's life.