Fixed state cloning bug in agents where state was being overwritten