Somebody who can threaten casters but die easily to a lockdown melee? That's pretty hard to imagine
To kill a caster:
1. Immune to divinations - maybe God-blooded of vecna
2. High SR. SR doesn't block everything, but it never hurts. Immunity to magic (aka golems) is even nicer.
3. Immunity to ability damage, fear, mind-control, the like. I'm thinking undead or construct by this point. But an insanely high SR also deals with most of this.
4. Permanent or easily raised protection from evil to deal with summoned creatures.
5. Can easily prevent teleportation. This one's tricky, and maybe impossible to pull off without spells.
6. High energy resistances.
7. Mobile - flying and freedom of action are probably the minimum here.
8. Has a means of dispelling magical buffs (Pierce magical concealment or warlock/DFA?)
9. Ideally, can stop spells while threatening (
10. Cannot be detected (Mundane hide + darkstalker, etc)
11. High saving throws
To die to a melee:
1. Low AC
2. Low HPs
3. Low strength score (to fail against trip, grapple, etc)
4. Few magic items
I think an undead or warforged swordsage with the right feats and 1-2 templates probably fits the bill best: lots of tricks against casters, but if built to fight casters, it won't have so many against direct melee damage.