How to reset tacker programmatically

Hi! I use Rasa programmatically by interacting with agent instance and I want to at some point reset the conversation completely. As far as I understand it this should be done by calling tracker._reset(). So I wrote very simple script to test it out. Unfortunately it didn’t work as expected, here’s the script:

import asyncio

from rasa.core.events import Restarted
from rasa.core.agent import Agent
agent = Agent.load('models/current.tar.gz')

async def handle(text, sender_id):
    response = await agent.handle_text(text, sender_id=sender_id)
    tracker = agent.tracker_store.retrieve(sender_id=sender_id)
    tracker._reset()
    print(response)

async def main() -> None:
    await handle("hi", "12345")
    await handle("hi", "12345")


if __name__ == '__main__':
    asyncio.run(main())

(Note: I am using exactly the same model as you get by calling rasa init) So the first message is handled correctly as expected. But second response is an empty list which is not something I would expect on first conversation.

So my question is how do I correctly reset conversation?

With the default action “action_restart”. You can overwrite this action with your own.

You can also return return the event “Restarted” from a custom action, including “action_restart” if you write your own.