One thing worth adding is that keeping the machine awake solves only the infrastructure side of the problem. It doesn’t guarantee the agent task survives a dropped API connection, terminal crash, or unexpected reboot.
For longer coding tasks, I’d treat caffeinate and tmux as convenience measures, but make the workflow resumable as well: persist task state, keep important outputs in files or commits, and make tool operations safe to retry. That way, even if the Mac does sleep, the work doesn’t have to start from zero. An always-on machine improves availability; recoverability is what makes the setup reliable.