agent: Improve support for externally cached passwords.