Simply checking the buffer-list is not enough, because an interactive command can be invoked via various ways, not just directly or via M-x. E.g. if you invoke it via a Helm-like selector package which creates various buffers for selection then the buffer list is affected.
Is there a reliable way to determine the origin buffer of a command which uses the minibuffer for input?