Is a reliable way to identify the caller with the following code?
bool isContract = msg.sender != tx.origin;
This should work. Also you can check the size of the code in the address if it is bigger than zero, is a contract
function isContract(address addr) returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
Hope this helps you
tx.origin
may also stop working in future Ethereum versions, especially as account abstraction work comes in.