---
title: "Keep an agent running with the lid closed · Kilobat Recipes"
url: "https://kilobat.app/guides/recipes/agent-lid-closed"
description: "Let a coding agent keep working with the Mac lid closed, with Kilobat's opt-in helper that still sleeps the Mac at a battery floor, when hot or after a limit."
---

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 later · You approve a helper in System Settings · Checked: 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](https://kilobat.app/docs#agents). Then an agent can call these tools. Tools that change settings tell the agent to ask you first.

| Tool and arguments | What it does |
|---|---|
| `get_conditions` | Shows `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_awake` | Ends 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](https://kilobat.app/guides/clamshell-lid-closed-mac).

**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](https://kilobat.app/guides/recipes/connect-agent-hooks).

## Sources

- [Kilobat docs: Running with the lid closed](https://kilobat.app/docs#lid-closed)
- [Kilobat skill: mac-agent-runs](https://github.com/seifip/kilobat-skills/tree/main/skills/mac-agent-runs)
- [Kilobat llms.txt: CLI and MCP reference](https://kilobat.app/llms.txt)

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

## Related guides

- [Keep a Mac laptop working with the lid closed](https://kilobat.app/guides/clamshell-lid-closed-mac): Closing the lid puts a Mac laptop to sleep.
- [Tell Kilobat when an agent waits or is done](https://kilobat.app/guides/recipes/connect-agent-hooks): Without hooks, Kilobat sees an agent only by its traffic and CPU.
- [Keep your Mac awake until a download finishes](https://kilobat.app/guides/recipes/keep-mac-awake-download): Kilobat keeps the Mac awake while transfers run.
- [Check the network before a big download in an agent](https://kilobat.app/guides/recipes/check-network-before-download): An agent can ask Kilobat if now is a good time for a large transfer.
