Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'action_two_stage_fallback' after choosing one of the intents in Two-stage-fallback #11294

Closed
cqx931 opened this issue Jul 5, 2022 · 4 comments · Fixed by #11407
Closed
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework triaged type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@cqx931
Copy link

cqx931 commented Jul 5, 2022

Rasa Open Source version

3.2.1

Rasa SDK version

No response

Python version

3.8

What operating system are you using?

Linux

What happened?

I'm trying to implement TwoStageFallback as described here. However, after the user clicks one of the intent options offered by the two-stage-fallback, the bot hangs by KeyError: 'action_two_stage_fallback'.

Command / Request

No response

Relevant log output

? Did you mean 'anfahrt'? 1: Yes (/anfahrt)                                                                                             
2022-07-05 09:22:46 DEBUG    rasa.core.lock_store  - Issuing ticket for conversation 'e2ead8b021f34276b8fcbed8c4205bf1'.
2022-07-05 09:22:46 DEBUG    rasa.core.lock_store  - Acquiring lock for conversation 'e2ead8b021f34276b8fcbed8c4205bf1'.
2022-07-05 09:22:46 DEBUG    rasa.core.lock_store  - Acquired lock for conversation 'e2ead8b021f34276b8fcbed8c4205bf1'.
2022-07-05 09:22:46 DEBUG    rasa.core.tracker_store  - Recreating tracker for id 'e2ead8b021f34276b8fcbed8c4205bf1'
2022-07-05 09:22:46 DEBUG    rasa.engine.runner.dask  - Running graph with inputs: {'__message__': [<rasa.core.channels.channel.UserMessage object at 0x7ff03008ae50>]}, targets: ['run_RegexMessageHandler'] and ExecutionContext(model_id='094c31c656f44e20991c0c9fa51a4da7', should_add_diagnostic_data=False, is_finetuning=False, node_name=None).
2022-07-05 09:22:46 DEBUG    rasa.engine.graph  - Node 'nlu_message_converter' running 'NLUMessageConverter.convert_user_message'.
2022-07-05 09:22:46 DEBUG    rasa.engine.graph  - Node 'provide_SpacyNLP0' running 'SpacyNLP.provide'.
2022-07-05 09:22:46 DEBUG    rasa.engine.graph  - Node 'run_SpacyNLP0' running 'SpacyNLP.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_SpacyTokenizer1' running 'SpacyTokenizer.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_SpacyEntityExtractor2' running 'SpacyEntityExtractor.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_SpacyFeaturizer3' running 'SpacyFeaturizer.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_LexicalSyntacticFeaturizer4' running 'LexicalSyntacticFeaturizer.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_CountVectorsFeaturizer5' running 'CountVectorsFeaturizer.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_EntitySynonymMapper6' running 'EntitySynonymMapper.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_DucklingEntityExtractor7' running 'DucklingEntityExtractor.process'.
2022-07-05 09:22:47 DEBUG    urllib3.connectionpool  - Starting new HTTP connection (1): localhost:8000
2022-07-05 09:22:47 DEBUG    urllib3.connectionpool  - http://localhost:8000 "POST /parse HTTP/1.1" 200 None
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_EntitySynonymMapper8' running 'EntitySynonymMapper.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_DIETClassifier9' running 'DIETClassifier.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_FallbackClassifier10' running 'FallbackClassifier.process'.
2022-07-05 09:22:47 DEBUG    rasa.nlu.classifiers.fallback_classifier  - NLU confidence 0.2501591742038727 for intent 'ermaessigung' is lower than NLU threshold 0.50.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_RegexFeaturizer11' running 'RegexFeaturizer.process'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'domain_provider' running 'DomainProvider.provide_inference'.
2022-07-05 09:22:47 DEBUG    rasa.engine.graph  - Node 'run_RegexMessageHandler' running 'RegexMessageHandler.process'.
2022-07-05 09:22:47 DEBUG    rasa.core.processor  - Received user message '/anfahrt' with intent '{'name': 'anfahrt', 'confidence': 1.0}' and entities '[]'
2022-07-05 09:22:47 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 15 events.
2022-07-05 09:22:47 DEBUG    rasa.core.lock_store  - Deleted lock for conversation 'e2ead8b021f34276b8fcbed8c4205bf1'.
2022-07-05 09:23:47 ERROR    asyncio  - Task exception was never retrieved
future: <Task finished name='Task-18' coro=<RestInput.on_message_wrapper() done, defined at /home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/rest.py:33> exception=KeyError('action_two_stage_fallback') created at /home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/rest.py:71>
source_traceback: Object created at (most recent call last):
  File "/home/qianxun/chatbot/venv/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/__main__.py", line 110, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/cli/shell.py", line 125, in shell
    rasa.cli.run.run(args)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/cli/run.py", line 126, in run
    rasa.run(**vars(args))
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/api.py", line 56, in run
    rasa.core.run.serve_application(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/run.py", line 225, in serve_application
    app.run(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/app.py", line 1204, in run
    serve_single(server_settings)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/server/runners.py", line 206, in serve_single
    serve(**server_settings)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/server/runners.py", line 155, in serve
    loop.run_forever()
  File "connection_task", line 15, in connection_task
    from sanic.http import Http, Stage
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/http.py", line 146, in http1
    await self.protocol.request_handler(self.request)
  File "handle_request", line 112, in handle_request
    from sanic_ext.extensions.base import Extension  # type: ignore
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/response.py", line 414, in stream
    await self.streaming_fn(self)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/rest.py", line 71, in stream
    task = asyncio.ensure_future(
Traceback (most recent call last):
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/rest.py", line 47, in on_message_wrapper
    await on_new_message(message)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/channel.py", line 89, in handler
    await app.ctx.agent.handle_message(message)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/agent.py", line 420, in handle_message
    return await self.processor.handle_message(  # type: ignore[union-attr]
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 147, in handle_message
    tracker = await self.run_action_extract_slots(message.output_channel, tracker)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 173, in run_action_extract_slots
    extraction_events = await action_extract_slots.run(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 1209, in run
    intent_is_desired = SlotMapping.intent_is_desired(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/shared/core/slot_mappings.py", line 112, in intent_is_desired
    + SlotMapping._get_active_loop_ignored_intents(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/shared/core/slot_mappings.py", line 93, in _get_active_loop_ignored_intents
    form_ignored_intents = domain.forms[active_loop_name].get(
KeyError: 'action_two_stage_fallback'
2022-07-05 09:23:47 ERROR    asyncio  - Task exception was never retrieved
future: <Task finished name='Task-6' coro=<SignalRouter._dispatch() done, defined at /home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/signals.py:121> exception=ClientResponseError(RequestInfo(url=URL('http://localhost:5005/webhooks/rest/webhook?stream=true&token='), method='POST', headers=<CIMultiDictProxy('Host': 'localhost:5005', 'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Python/3.8 aiohttp/3.7.4', 'Content-Length': '69', 'Content-Type': 'application/json')>, real_url=URL('http://localhost:5005/webhooks/rest/webhook?stream=true&token=')), (), status=503, message='Service Unavailable', headers=<CIMultiDictProxy('Content-Length': '79', 'Connection': 'close', 'Content-Type': 'application/json')>) created at /home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/signals.py:193>
source_traceback: Object created at (most recent call last):
  File "/home/qianxun/chatbot/venv/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/__main__.py", line 110, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/cli/shell.py", line 125, in shell
    rasa.cli.run.run(args)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/cli/run.py", line 126, in run
    rasa.run(**vars(args))
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/api.py", line 56, in run
    rasa.core.run.serve_application(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/run.py", line 225, in serve_application
    app.run(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/app.py", line 1204, in run
    serve_single(server_settings)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/server/runners.py", line 206, in serve_single
    serve(**server_settings)
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/server/runners.py", line 151, in serve
    loop.run_until_complete(app._server_event("init", "after"))
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/app.py", line 2000, in _server_event
    await self.dispatch(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/signals.py", line 191, in dispatch
    return await dispatch
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/signals.py", line 161, in _dispatch
    retval = await maybe_coroutine
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/app.py", line 1524, in _listener
    await maybe_coro
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/app.py", line 1575, in dispatch_delayed_tasks
    await app.dispatch(name, context={"app": app, "loop": loop})
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/signals.py", line 193, in dispatch
    task = asyncio.get_running_loop().create_task(dispatch)
Traceback (most recent call last):
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/signals.py", line 161, in _dispatch
    retval = await maybe_coroutine
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/sanic/app.py", line 1581, in run_delayed_task
    await prepped
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/run.py", line 135, in run_cmdline_io
    await console.record_messages(
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/console.py", line 205, in record_messages
    async for response in bot_responses_stream:
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/rasa/core/channels/console.py", line 151, in _send_message_receive_stream
    async with session.post(url, json=payload, raise_for_status=True) as resp:
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 625, in _request
    resp.raise_for_status()
  File "/home/qianxun/chatbot/venv/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1000, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 503, message='Service Unavailable', url=URL('http://localhost:5005/webhooks/rest/webhook?stream=true&token=')
x
@cqx931 cqx931 added area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. labels Jul 5, 2022
@ancalita
Copy link
Member

@cqx931 I've been trying to reproduce the reported bug with rasa version 3.2.4 and so far I haven't been able to do so.
I used a rasa init project to which I added a rule as described in the docs to enable two-stage-fallback.
After I trigger action_two_stage_fallback, I get the expected ? Did you mean 'mood_unhappy'? 1: Yes (/mood_unhappy) and after selecting the Yes option, everything executes as expected, without the KeyError.

Could you please try again with 3.2.4 and see if this behavior occurs again for you? If so, please share your example repo via a public link.

@wise175
Copy link

wise175 commented Jul 28, 2022

Dear @ancalita, apparently the bug occurs when there are slots declared or in use. Attached repository link that reproduces the reported bug with rasa version 3.2.4.

Rasa Open Source version
3.2.4
Rasa SDK version
3.2.0
Python version
3.8.10
What operating system are you using?
Linux
Link repo example:
https://github.com/wise175/two_stage_fallback_test

I hope it helps to solve this bug.

Best regards

@Maximilian-Ka
Copy link

For those who can't upgrade their Rasa version because they are still testing Rasa Enterprise through RasaX:

The blogpost Handling-chatbot-failure-gracefully helped me to circumvent this issue and at the same time print out user friendly messages in the fallback 😄

@ancalita
Copy link
Member

ancalita commented Aug 5, 2022

Fix has just been released in version3.2.5.

@ancalita ancalita closed this as completed Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework triaged type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
4 participants