That would mean this line:

rpc_client = rpcclient(agent, flags)

can return nil.  Is that the case?  Would be a strange pattern.  If it does we should catch the issue there and raise the exception immediately.  And secondly if it does, this wouldn't be the right fix since rpc_client is referenced several times before it gets to this point.