A messaging extension is associated with a Microsoft Teams bot. When invoked, such as for getting search results, it sets up a conversation with the bot it was associated with. That bot is aware of the Teams user X who invoked the messaging extension.
However, is it possible to know the context in which the messaging extension was invoked, for example it was invoked during a 1:1 Chat session with remote user Y? The use case is to return results in the messaging extension based on the identity of the remote user Y, and not just the identity of X.