it's not really weird because the decision of a counterattack is decided before the evaluation of the formula. it's not really a problem of this plugin because it's the same as the default battle system. before it worked because it applied the formula before the execution of the action.
the formula is evaluated only once during the execution of the action. and it is the last instruction that defines the damage (b.addState(b); in your example). in addition, it is like adding a state and removing it immediately.
what you need is to add a state before the action and remove it after the action. i think this is possible but not with the skill formula.
the easiest way to do this will be to write a script. as being curious, i quickly wrote a script to simulate a counterattack like in the fire emblem series. it's experimental and i can't support this plugin. i have to fix all the problems of the basic system first.
Counter Attack applies the same formula as the last fire emblem for the double attack. it checks that action.speed() > b.agi + 4 [action.speed() = a.agi + action.speed]. you can manually change this directly in the script but I should normally write a parameter directly accessible from the plugin manager. distance ranged attacks are not counter like archers are. as i said, this is a script I wrote quickly and is probably full of little problems that I can't fix now or forever. i also added a tag <Can Counter:false> for a skill but I don't know if it works because I never tried it.
edit: actually, I don't know if it works with the current version on github. maybe you should wait until I push the new version.