https://www.englishclub.com/grammar/tag-questions.htm
says:
Answer a tag question according to the truth of the situation. Your
answer reflects the real facts, not (necessarily) the question.
I think (but am not sure) that answering the tag is the right way to think about it; but the tag is just a reversal of the statement to which it's attached; so it seems to be the same thing.
Kids are bad, aren't they? Yes, they are (they are bad); No, they aren't (they aren't bad, they're good).
Kids aren't bad, are they? Yes, they are (bad); No, they aren't (bad). They're good.
You didn't finish your homework, did you? No, I didn't. Yes, I did.
The important point, in which English apparently differs from other languages, is that your answer to the tag question is not a confirmation of whether the view expressed by the original question is right or wrong. So, you didn't finish your homework. The answer is not "Yes, you're right, I didn't finish my homework." It's "No", because you didn't finish it.
You finished your homework, didn't you? Yes, I finished my homework. No, I didn't finish my homework.
You're going grocery shopping today, aren't you? No, I'm not. Yes, I am.
Kid are a lot of trouble, aren't they? Yes, kids are a lot of trouble. No, kids are really not that much trouble.
Kids aren't a lot of trouble, are they? No, they're not. [Yes, actually they are a lot of trouble.]
The questioner who's adding the tag is usually asking for confirmation, which doesn't mean the usual answer is yes.
Does that help? Can anyone think of a tagged question for which this doesn't work?