Goal Stack
Here’s a suggestion for building in some higher-level intelligence into a conversational rasa agent in a simple way.
I just read the suggested strategy for handling context switching, which I think makes sense given the purely simple-ML-based dialog management Rasa is currently designed to support.
But it seems like this approach will require us to write enough stories that, in the worse case scenario, we must create examples for all possible pairs of intents if the chatbot is supposed to handle even a single level of nesting / context switching. What if there are many possible intents and you want to allow for more than a single nested context switch? The size of this example space grows exponentially.
There is a better way to structure the dialog behind the scenes that does not create an explosion of context complexity or required training examples.
I think you will find that we need to move beyond a purely-ML-based dialog management strategy sooner or later. It will help to remember some techniques from other areas of AI and computer science. In agent-based AI, such as in the good old cognitive modeling architectures from the 1990’s like SOAR and ACT-R, intelligent decision-making was built on top of simple CS concepts like goals and search. I will save the topic of search for another day. For now, consider goals, which I think is still a very useful construct to incorporate into a dialog agent. An intent really just indicates a goal state that the user and chatbot are trying to reach in a series of steps.
A simple place to start applying goals as a first-class concept would be in context switching. Simply maintain a goal stack in Rasa. Then, if the current intent is interrupted, put the current goal (which corresponds to that intent) on the goal stack. Once the nested goal is handled, go back to the goal on the top of the goal stack. If the nested goal is interrupted with third intent before it is completed, put the second goal on the stack, and handle the third goal. Continue to pop goals off the stack until they are all fulfilled. And so forth, und so weiter. Now we only need to provide training examples for each goal/intent, individually, not in combination with all the other intents.
A good example of the current requirement to supply more training examples than should be necessary is in this TED in Practice whiteboard: Rasa Algorithm Whiteboard - TED in Practice - YouTube