github.com via Hacker News

Adrafinil keeps Mac awake precisely during AI agent sessions

agents coding tools dev-tools agents

TL;DR

  • Adrafinil monitors nine AI coding agents and blocks Mac sleep only while a session is active, restoring normal sleep the moment it ends.
  • The MIT-licensed Swift app uses a three-tier architecture: an unprivileged LaunchAgent for assertions, a privileged LaunchDaemon for sleep APIs, and a sub-50ms CLI.
  • A thermal cutout automatically releases sleep assertions if temperatures exceed safe thresholds while the lid is closed.

Every developer running overnight agentic coding sessions has hit the same wall: the laptop goes to sleep mid-task, the agent stalls, and the next morning reveals a half-finished job. Adrafinil, an MIT-licensed macOS menu bar utility at v1.1.2, targets exactly this problem by blocking sleep only while an AI coding agent session is active and releasing the assertion the moment it finishes.

The project integrates with nine agents through hook systems: Claude Code, Codex, Cursor, Gemini CLI, Aider, Hermes, OpenCode, Cline, and Pi. Under the hood it uses a three-tier architecture spanning three privilege levels: a user-facing menu bar app, an unprivileged LaunchAgent that manages sleep assertions and monitoring, and a privileged LaunchDaemon called AdrafinilHelper that handles sleep APIs exclusively. A CLI tool communicates with the daemon over sockets in under 50ms, keeping overhead low enough that it won't visibly slow an agent workflow.

Two safety details stand out. A thermal cutout automatically releases sleep assertions if temperatures exceed safe thresholds while the lid is closed, preventing the machine from overheating during an unattended session. An optional lid-state audio chime confirms the assertion is held on closure. What the project does not describe is what happens to a running agent when the thermal cutout fires: whether the agent receives a signal or simply loses its power assertion mid-task is an open question.

The honest caveat on adoption is the macOS Tahoe 26.4 requirement, which means the app is tightly coupled to a specific OS release and an Apple API change could break it quickly. The AdrafinilHelper component also requires admin rights at install, so developers are granting elevated trust to a third-party daemon, worth reviewing before deploying on a machine holding sensitive credentials.

With 118 stars on GitHub and nine agents already covered, Adrafinil sits squarely in the emerging category of tooling that makes long agentic sessions practical rather than fragile. The MIT license means teams can adapt the hook system for custom agents without restriction, and the optional process monitoring mode lowers the setup bar for developers who do not want to configure per-agent hooks by hand.