Back to List
Adrafinil: A New macOS Utility Designed to Keep Laptops Awake Exclusively During AI Agent Activity
Product LaunchmacOSAI AgentsOpen Source

Adrafinil: A New macOS Utility Designed to Keep Laptops Awake Exclusively During AI Agent Activity

Adrafinil is an innovative macOS menu bar application that introduces a "eugeroic" approach to machine power management. Unlike traditional utilities that keep a computer awake indefinitely, Adrafinil prevents a Mac from sleeping—including in clamshell (lid-closed) mode—only while an AI coding agent is actively performing a task. Supporting popular agents such as Claude Code, Codex, and Cursor, the tool ensures that long-running AI sessions are not interrupted when the user closes the laptop lid. Once the agent completes its work and releases the session, Adrafinil allows the system to return to its normal sleep behavior immediately. By utilizing a secure, audited helper for privileged sleep control and standard system assertions, Adrafinil offers a specialized solution for developers and AI users who require automated, task-aware system wakefulness.

Hacker News

Key Takeaways

  • Agent-Aware Power Management: Adrafinil only prevents sleep when at least one AI agent session is active, distinguishing it from "always-on" utilities.
  • Clamshell Mode Support: The tool allows a Mac to continue working with the lid closed, specifically overriding default macOS sleep behavior for active tasks.
  • Broad Integration: It features hook integration for nine different agents, including Claude Code, Codex, and Cursor.
  • Security-First Architecture: To handle privileged sleep overrides, Adrafinil uses a tiny, audited helper to isolate root-level commands from the main application logic.
  • Automated Efficiency: The system returns to normal sleep settings the moment the last active agent session finishes, ensuring no unnecessary power consumption.

In-Depth Analysis

The "Eugeroic" Philosophy vs. Traditional Stimulants

In the realm of macOS power management, tools like caffeinate and Amphetamine have long served as "stimulants" for hardware, keeping the machine "wired" and awake regardless of whether actual work is being performed. Adrafinil introduces a different philosophy, described by its creators as a "eugeroic" for machines. In medical terms, a eugeroic is a wakefulness-promoting agent; applied to software, Adrafinil acts as a smart intermediary that only intervenes when there is a specific reason for the machine to stay awake.

The primary use case addressed is the late-night developer workflow. When a user starts a complex AI agent session at 3 a.m. and decides to go to sleep, they often close the laptop lid. Under normal circumstances, this would suspend the AI's progress. Adrafinil solves this by monitoring the state of the AI agent. If an agent is "mid-thought," the utility keeps the system active. The moment the agent finishes its task, the utility "gets out of the way," allowing both the user and the machine to sleep normally. This "agent-aware" logic ensures that the hardware state is always synchronized with the software's workload.

Technical Implementation and Security

Overriding the macOS "clamshell" sleep (lid-closed sleep) is a privileged operation that requires root access. To maintain a high standard of security, Adrafinil does not run the entire application with elevated privileges. Instead, it employs a bifurcated architecture. All policy decisions and user interface elements live in an unprivileged daemon. The actual sleep override is handled by a "tiny, audited helper" that only exposes a single function: setSleepBlocked(Bool).

Technically, the application manages sleep through two primary mechanisms. For standard idle sleep, it holds a standard IOPMAssertion. For the more complex task of preventing sleep when the lid is closed, it utilizes the pmset disablesleep command. The developers noted that they verified this approach on-device after determining that cleaner, private IOPMrootDomain paths were insufficient for keeping a displayless, lid-closed Mac awake. This robust technical foundation ensures that the utility works reliably across different macOS power states while minimizing the security surface area.

Integration and User Experience

Adrafinil is designed for ease of use within the modern AI development ecosystem. It includes a one-click installer that wires the utility into a hook system, allowing it to detect sessions from various AI tools automatically. Currently, the project supports nine different agents, specifically mentioning high-profile tools like Claude Code, Codex, and Cursor.

The user experience is centered around a menu bar app that provides a "zero-intervention" workflow. Once installed and configured, the user does not need to manually toggle the app on or off. The transition from "blocked sleep" to "normal sleep" is entirely dependent on the presence of active agent sessions. This automation removes the cognitive load of remembering to disable a wake utility after a task is finished, preventing the common issue of a laptop staying awake in a bag and overheating or draining its battery.

Industry Impact

The release of Adrafinil highlights a growing trend in the AI industry: the shift from interactive AI to autonomous, long-running agents. As AI agents move from simple chat interfaces to complex, multi-hour coding and reasoning tasks, the underlying operating systems and hardware management tools must evolve to support these "background" workloads.

Adrafinil represents a niche but essential category of "agent-aware infrastructure." By bridging the gap between high-level AI task states and low-level system power management, it enables a more seamless integration of autonomous agents into the daily lives of developers. Furthermore, its open-source nature and focus on audited, minimal-privilege code set a standard for how third-party utilities should handle sensitive system controls in an era where security is paramount.

Frequently Asked Questions

Question: How does Adrafinil differ from apps like Amphetamine or the native 'caffeinate' command?

Adrafinil is "agent-aware" rather than "always-on." While Amphetamine and caffeinate keep a Mac awake until a timer runs out or a user manually toggles them off, Adrafinil only blocks sleep while an AI agent (like Claude Code or Cursor) is actively working. It automatically allows the Mac to sleep the moment the agent finishes its task.

Question: Does Adrafinil require special permissions to work with the lid closed?

Yes. Preventing a Mac from sleeping when the lid is closed (clamshell mode) requires root privileges. Adrafinil handles this securely by using a small, audited helper tool that specifically manages the setSleepBlocked command, while the rest of the app runs without elevated privileges.

Question: Which AI agents are currently supported by Adrafinil?

Adrafinil features hook integration for nine agents. The documentation specifically highlights support for Claude Code, Codex, and Cursor, ensuring that these tools can maintain active sessions even if the user closes their laptop lid.

Related News

Meituan Unveils LongCat-2.0: A 1.6 Trillion Parameter Model Optimized for Agentic Coding on Domestic Clusters
Product Launch

Meituan Unveils LongCat-2.0: A 1.6 Trillion Parameter Model Optimized for Agentic Coding on Domestic Clusters

Meituan's technical team has officially announced the release of LongCat-2.0, a pioneering large-scale model featuring 1.6 trillion total parameters. This model distinguishes itself as the industry's first trillion-parameter model to complete its entire training and inference lifecycle on a domestic computing cluster consisting of 50,000 cards. LongCat-2.0 was pre-trained from scratch and natively supports a 1-million-token long context window. With an architecture designed for efficiency, it maintains an average of 48 billion active parameters within a dynamic range of 33B to 56B. The model is specifically engineered to enhance the stability and performance of 'Agentic Coding' tasks, focusing on the comprehensive understanding, generation, and execution of code in real-world scenarios.

PostHog Emerges as a Leading Platform for Building and Optimizing Self-Driving AI Products
Product Launch

PostHog Emerges as a Leading Platform for Building and Optimizing Self-Driving AI Products

PostHog has established itself as a comprehensive platform designed specifically for the development of self-driving products and intelligent agents. By integrating a wide array of developer tools—including AI observability, session replay, feature flags, and error tracking—PostHog enables developers to capture the full context required for diagnosing complex issues within autonomous systems. The platform's focus on providing deep diagnostic insights allows teams to identify growth opportunities and deploy critical fixes efficiently. As the demand for sophisticated AI agents grows, PostHog’s unified approach to analytics and observability offers a streamlined solution for developers looking to maintain high performance and reliability in their automated products, ensuring that every agent action is backed by actionable data and comprehensive logging.

PrismML-Eng Debuts Bonsai-demo: A New Demonstration Repository Reaches GitHub Trending Status
Product Launch

PrismML-Eng Debuts Bonsai-demo: A New Demonstration Repository Reaches GitHub Trending Status

PrismML-Eng has officially released the "Bonsai-demo" repository, a project designed to provide a functional demonstration of the Bonsai framework. Shortly after its publication on July 18, 2026, the repository gained significant traction, appearing on the GitHub Trending list. The project, primarily identified by its title "Bonsai 演示" (Bonsai Demo) and a distinct logo asset, serves as a central hub for users to explore the capabilities of PrismML-Eng's latest developments. While the repository is in its early stages, its rapid ascent in popularity highlights a growing interest within the open-source community for the tools being developed by the PrismML engineering team. This release marks a key milestone in the project's lifecycle, focusing on accessibility and visual representation through its dedicated demo assets.