Added error checks in ShellAgent to avoid death due to bad requests