agent: Improve test reliability