added an agent spec and some retry logic