It's just not as clear cut as you want it to be.
http://www.nclawreview.org/2014/08/...and-the-responses-of-other-government-actors/
Article discussing the "duty to defend"
http://www.yalelawjournal.org/feature/state-attorneys-general-and-the-duty-to-defend
Yale Law Journal take on AG "duty to defend"
"Unlike state constitutions, state statutes invariably speak to the power and responsibilities of the attorneys general.109 Most state statutes provide that the attorney general is to represent (or appear on behalf of) the state or has a duty to represent it. As noted with respect to similar constitutional provisions, such language is rather equivocal because it is hard to tease out implications about when attorneys general may (or must) defend (or concede the invalidity of) state law. A handful of states have more specific directives. Two states mandate that their attorneys general defend the constitutionality of state law (Pennsylvania and Mississippi).110 Tennessee clearly empowers its attorney general to refuse to defend laws she finds unconstitutional.111 Louisiana has a suggestive but ambiguous statute. It provides that the attorney general “at his discretion, shall represent . . . the state in any action or proceeding in which the constitutionality of a state statute or of a resolution of the legislature is challenged or assailed.”112It is suggestive because one might conclude that the Louisiana Attorney General may choose, “at his discretion,” not to defend the constitutionality of state law. By statute, Nebraska compels its attorney general to challenge the constitutionality of state law whenever two preconditions are satisfied: first, she has previously opined that the law is unconstitutional, and second, a state officer refuses to enforce the law in reliance on that opinion.113 This express duty to attack is somewhat narrow because it only applies when the two preconditions are met.
Even when codified state law imposes an obligation to defend, the duty’s implications are rather uncertain and raise a host of questions. What sort of arguments must the attorney general make at trial or on appeal? Any argument, even if implausible? Only plausible arguments? Or only those arguments that actually persuade the attorney general, meaning that if there are none, she need not mount a defense even if others think there is a plausible argument? Relatedly, must she advance (plausible or persuasive) legal arguments that the state supreme court or the U.S. Supreme Court has previously rejected in another legal context? What if a supreme court has already declared a state law to be unconstitutional (or otherwise preempted)? Must the attorney general nonetheless make the same arguments again because she has a duty to defend and hope that the supreme court will change its view?
There is the separate issue of whether to appeal. In particular, must the attorney general with a duty to defend appeal unfavorable trial court judgments that strike down state law? If so, must she continue to appeal until the highest court rules?114 One might suppose that anything short of continual defense, however futile, violates the duty to defend. Yet one might also imagine that duties have implicit limits and that context matters. Though soldiers are duty-bound to defend their country, that obligation is not unyielding, for even soldiers may surrender to the enemy in certain circumstances.115 Similarly, one might suppose that the duty to defend applies only when a defense has a prospect of success in the courts."