Form filling slot after user replying out of scope message [SOLVED]

I have the following story:

story: survey continue                                                      
  steps:                                                                   
  - intent: greet                                                          
  - action: utter_greet                                                    
  - intent: affirm                                                         
  - action: health_form                                                    
  - active_loop: health_form                                               
  - intent: out_of_scope                                                   
  - action: utter_ask_continue                                             
  - intent: affirm                                                         
  - action: health_form                                                    
  - active_loop: null                                                      
  - action: utter_slots_values 

And let’s assume the following conversation:

1 Me: hello
2 Bot: Hi! It's time for your daily wellness check. Tracking healthy habits is a great way to measure your progress over time. Would you like to answer a few questions about your health?
3 Me: yes please
4 Bot: Did you exercise yesterday? Don't sweat it if you didn't run a marathon - walks count!
5 Me: wait stop
6 Bot: Sorry, I don't quite understand. Do you want to continue?
7 Me: actually yes
8 Bot: What kind of exercise did you do?

As you can see, in the 7th message if the user makes an affirmation intent it answers the question proposed in the 6th message as well as the one proposed in the 4th message.

I would expect a conversation flow like this:

[...]
6 Bot: Sorry, I don't quite understand. Do you want to continue?
7 Me: actually yes
8 Bot: Did you exercise yesterday? Don't sweat it if you didn't run a marathon - walks count!

Is this expected behavior? How can I achieve the expected flow that I have in mind?

If more info is needed to better clarify the problem let me know. I’m new to this framework, I’ve started coding in it literally last week.

Solution

In actions.py add a more restrictive conditional to those extract_<slot_name> functions that modify the bot’s memory with the same intent as the one answering the utter_ask_continue question.

if (not tracker.slots.get('requested_slot') == "confirm_exercise" or tracker.get_last_event_for(event_type="action", exclude=["health_form"], skip=1)['name'] == "utter_ask_continue"):
  return {}

Check this GitHub issue to get full disclosure on the solution.