Added check for agentResponse