Recipe

Keep an agent running with the lid closed

Closing the lid puts a Mac laptop to sleep. Kilobat has an opt-in helper that keeps a working agent run going with the lid closed.

Kilobat 1.3 or laterYou approve a helper in System SettingsChecked: 29 October 2026

In the app

  1. Open Settings in Kilobat and find Awake & agents.

  2. Turn on Allow running with the lid closed.

  3. When macOS asks, approve Kilobat’s power helper in System Settings > General > Login Items.

  4. Set Longest with the lid closed. The limit is 8 hours.

  5. Set the battery level at which the Mac sleeps. The default is 20%.

  6. Turn on Keep the Mac awake while AI agents work.

  7. For an awake session, open the teacup menu and choose With the Lid Closed Too.

With the CLI

  1. Make sure that the setting is on and see the current hold.

    kilobat conditions --json

    Output lidClosedAllowed and lidHold, with the battery level and heat state under power.

  2. Keep running with the lid closed for two hours.

    kilobat awake --lid-closed --for 2h
  3. Keep running with the lid closed while one command runs. The hold ends with the command.

    kilobat awake --lid-closed -- npm test

Through MCP

Connect the MCP server once with claude mcp add kilobat -- kilobat mcp. For other clients, see the docs. Then an agent can call these tools. Tools that change settings tell the agent to ask you first.

Tool and argumentsWhat it does
get_conditionsShows lidClosedAllowed and lidHold.
keep_awake
{"minutes": 120, "reason": "Agent run", "lid_closed": true}
Keeps the Mac running with the lid closed. The tool tells the agent to get your confirmation each time.
release_awakeEnds the hold.

Good to know

  • A closed Mac in a bag can become hot, and its battery can go flat. Connect the power adapter if you can.
  • The helper lets the Mac sleep at your battery floor, when it is hot, after the time limit, and one minute after Kilobat quits.
  • An agent that waits for you holds the lid for 30 minutes at most. This needs Keep awake while an agent waits for you.
  • If the helper or the Mac restarts while it holds the lid, the helper puts the setting back first.

Questions

Can I do this without Kilobat?

macOS keeps a laptop awake with the lid closed in closed-display mode, with an external display and power. See Keep a Mac laptop working with the lid closed.

Does an agent need its hooks for this?

No. Kilobat sees agents by their traffic. Hooks tell it when a run waits or is done. See Tell Kilobat when an agent waits or is done.

Sources

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.