Confusing merge conflicts in stories and intent files


When Rasa 1.0 came out, our team had just started using it to create our first chatbot. Today, around 18 months later, we have yet to find a clean way of avoiding big merge conflicts inside our data files. For example, when re-ordering stories or when moving phrases from one intent to another, we always have to face a lot of merge conflicts when merging to master.

To an extent, this is natural, as we know that the merges are based on the diffs and git’s diff is not aware of the semantics of the yaml (or md) files. For example, after removing a story and adding another - a pretty simple change - git diff gives us a very confusing result:

< - story: unhappy Whats_your_name, Pharma_search, Am_I_Ill (interactive)
> - story: unhappy Covid_Stats, Am_I_Ill
<   - intent: Greetings
<   - action: action_utter_greetings
<   - action: utter_use
<   - intent: Whats_your_name
<   - action: utter_name
<   - action: utter_fuse
<   - intent: Pharma_search
<   - action: pharmacy_form
<   - active_loop: pharmacy_form
<   - slot_was_set:
<     - requested_slot: requested_city
<   - intent: Am_I_Ill
>   - intent: Covid_Stats
>   - action: covid_statistics_form
>   - active_loop: covid_statistics_form
>   - intent: What_to_do_if_positive
<   - action: ill_questionnaire_form
<   - active_loop: ill_questionnaire_form
<   - slot_was_set:
<     - requested_slot: has_cough
<   - slot_was_set:
<     - has_cough: true
<   - slot_was_set:
<     - requested_slot: has_fever
<   - slot_was_set:
<     - has_fever: false
<   - slot_was_set:
<     - requested_slot: has_SOBreath
<   - slot_was_set:
<     - has_SOBreath: false
<   - slot_was_set:
<     - requested_slot: has_Anosia
<   - slot_was_set:
<     - has_Anosia: true
<   - slot_was_set:
<     - requested_slot: has_Ageusia
<   - slot_was_set:
<     - has_Ageusia: false
<   - slot_was_set:
<     - requested_slot: null
<   - active_loop: null
<   - action: ill_questionnaire_form_submit
>   - action: utter_what_to_do_if_positive

My question is how do you handle merge conflicts in such files? Has anybody implemented a merge algorithm that takes into account the semantics of stories and intents? The only related thing I have found is Unity’s smart merge for yml files but I haven’t tried it out yet.

Just to check, are these merge conflicts caused by Rasa X or are these caused by manual changes to the NLU files?

Mostly the manual ones.

Really bad merge conflicts are mostly caused by manual changes in the stories file (most frequently) or in the nlu data files (less frequently). We use Rasa X too, but only its NLU inbox feature, which has produced some merge conflicts but nothing hard to solve.

The most annoying cases, by far, are when stories get mixed up. Then, we have to consult the two different file versions before the merge. I have thought of one workaround - however I would like to look around more before resorting to it. It may be a bit extreme, but keeping every story in its own file would eliminate the problem completely. In general, splitting stories in as many files as possible will make merge conflicts much more manageable.