rasa: custom action_session_start can't access user message metadata
Rasa version: 2.1.1
Rasa SDK version (if used & relevant): 2.1.2
Rasa X version (if used & relevant): n/a
Python version: 3.7.9
Operating system (windows, osx, …): ubuntu 20.04
Issue: Same issue as: https://github.com/RasaHQ/rasa/issues/6348
“Trying to pass metadata to slots using action_session_start; the events key on the tracker data, on the action server request, is arriving empty.”
This issue is not present on 1.10.14.
Error (including full traceback):
2020-11-30 14:58:06 WARNING actions.actions - session_start but no metadata, tracker.events: []
Command or request that led to error:
Content of configuration file (config.yml) (if relevant):
Content of domain file (domain.yml) (if relevant):
Additional Details (added by @wochinge )
The use case for this is that the first user message contains metadata which is supposed to be passed onto the action_session_started action. To make this a bit more tricky action_session_started is overriden by a custom action.
The problem is a custom action can only access information from the past. However, action_session_started is the first event in the conversation and there is no past (as we execute the session initializtion before we log the UserUttered event). We hence have the task to make metadata available to the custom action before this action actually happened.
Visualization of the problem:
- User sends first message
InputChannelextras metadata and passes it along with theUserMessageprocessorfinds out this is the first message in the conversation and runsaction_session_startwhich is a custom actionaction_session_startruns but has no access on the metadata from theUserMessage- processor logs
action_session_started+ theSessionStartedevent on the tracker - the processer runs the NLU prediction and logs it on the tracker (together with the metadata)
- the processor predicts and executes further bot actions
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 30 (25 by maintainers)
If users decide dynamically in their custom
action_session_startedto not restart the session, they’d have to also revert the potentiallysession_startedevent which was added for the metadata. Unfortunately nobody asked in the removal PR what the actual reason was to remove this so I can only guess that this might have been the reason. Having twosession_startedevents definitely wouldn’t be clean.You mean in case
action_session_startisn’t overriden? We can still keep this.We can make the slot value an arbitrary payload.
👍🏻 Open for renaming suggestions. Note that the entire idea is that we log the metadata as event so the custom
action_session_startedaction can access this data.What side effect are you thinking of.
This sounds like a breaking change. Existing implementations count on
action_session_startincluding metadata. The user can also structure their metadata in any fashion they want. The proposed change seems like it would require a formal definition of a metadata object that isn’t currently required.Minor point but the idea of a slot called
action_session_start_metadatais confusing because it implies to me that it is an Event.@wochinge Understood. Thanks for the reply.
Assuming you guys would be busy with minor release If we can decide on solution, then I can also help with creating the PR.
if action.name() == ACTION_SESSION_START_NAME: action.metadata = metadataIf you do this, this metadata is only passed to default action_session_start ( which is inside rasa OSS ), but we do custom implementation of this action ( which is remote ) and then this metadata is not available. As call to remote action does not have that parameter and attribute you set on "action.metadata = metadata " will not transmit to custom remote action. As tracker is empty, metadata info is lost.async def run( self, output_channel: "OutputChannel", nlg: "NaturalLanguageGenerator", tracker: "DialogueStateTracker", domain: "Domain", ) -> List[Event]There is no metadata passed in run method and tracker is empty, metadata used to be in tracker at session start.