How to clear event history using in memory tracker store?

RASA: 1.6 OS: Ubuntu

I’m using an in memory tracker store. After many turns of conversation, rasa become slower and slower. Checked the log and then I find that every time rasa core extract all events and send to action server. Related logs following:

2020-08-04 10:30:21 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 23242 events.

2020-08-04 10:30:21 DEBUG    rasa.core.processor  - Predicted next action 'form_xx' with confidence 1.00.
2020-08-04 10:30:21 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'form_xx'.
/usr/local/miniconda3/lib/python3.6/site-packages/aiohttp/payload.py:228: ResourceWarning: Sending a large body directly with raw bytes might lock the event loop. You should probably pass an io.BytesIO object instead

I checked action call data, and found that it’s very big. Waiting for your reply. Thank you very much.

Hi, the InMemoryTrackerStore always stores the whole conversation history and there is no nice way to clear it. Also, there shouldn’t be, because that would mean that in the middle of the conversation the bot suddenly “forgets” everything that was said.

What you can do is to use a custom tracker store instead for which you specify a maximum number of events to store. How to add a custom tracker store is described in our docs. Set up your custom tracker store to use a tracker with the parameter max_event_history set to some number instead of None .

E.g. your tracker store class could look similar to this:

class InMemoryTrackerStoreLimited(InMemoryTrackerStore):

    def __init__(
        self, domain: Domain, url: Text, event_broker: Optional[EventBroker] = None, max_event_history: Optional[int] = 60
    ) -> None:
        super().__init__(domain, event_broker)
        self.max_event_history = max_event_history

Another example of a custom tracker store limiting the event number (using Mongo) can be found in this blogpost.

1 Like