Qwen Code was still working.
Your Mac didn't care.

If macOS went to sleep mid-task, Qwen Code froze right where it was. It didn't fail; it got paused along with your Mac. Here's why that happens, how to stop it, and why the terminal version and the desktop app need different answers.

To keep your Mac awake while Qwen Code runs: the free way is macOS's built-in caffeinate — start your session as caffeinate -i qwen and the Mac can't idle-sleep until the agent exits. The automatic way is AgentBarista, which watches for real agent activity and lets your Mac sleep once the work is done. Qwen Code (the CLI) is in AgentBarista's built-in agent list. The desktop app is recognised as running but has no work signal yet, so don't rely on it for unattended runs. The honest status of both is below.

The direct answer

Why your Mac sleeps while Qwen Code is still going

Qwen Code spends most of a task waiting on a model response — which barely uses any CPU. But macOS doesn't decide from CPU at all — it goes by your idle time, how long since real keyboard or mouse input, plus the power assertions running processes hold. So working hard doesn't protect the machine: a Mac mid-refactor sleeps on exactly the same schedule as one doing nothing. After your system-sleep timer runs out, macOS suspends the Mac, and the qwen process is frozen along with everything else until you wake it back up.

This bites hardest on the runs worth walking away from: a long plan-then-edit pass across a repo, a big test-and-fix loop, or anything you kicked off and left alone. The fix is to stop macOS from sleeping for as long as the agent is actually running — then let it sleep normally again once the run is done. You can do that for free in two minutes, or with a tool that watches for real agent activity so you don't have to babysit it.

The free option

Free tools can keep your Mac awake too

If you only run Qwen Code occasionally, you don't need to buy anything. Because it's a terminal agent, the cleanest free fix is one command:

  • The built-in caffeinate command. Launch your session as caffeinate -i qwen instead of qwen. The Mac can't idle-sleep while the agent runs, and the moment Qwen Code exits, normal sleep is allowed again — nothing to remember to undo. Already on your Mac, free. For a scripted, non-interactive run, wrap the whole command the same way: caffeinate -i qwen -p "your instruction".
  • Attach to a session you already started. You don't have to restart it. Check what's running first with pgrep -lf qwen, then hold sleep off until that exact process exits with caffeinate -i -w <pid>. The -f form is needed here because Qwen Code is a Node program installed from npm, so what macOS lists as the process is often node with the qwen script in its arguments — a plain pgrep qwen finds nothing. The trade-off: -f also matches anything else with "qwen" in its command line, so read the list and pick the PID by hand rather than piping it straight in.
  • Amphetamine (free, Mac App Store). A menu-bar toggle to keep the Mac awake on a timer or while your terminal app is open — handy if you'd rather flip a switch than type a command.

All of these are a fine choice if Qwen Code runs for a few minutes here and there. The catch: none of them knows when the agent actually finished a task versus when it's just sitting at an idle prompt. You either stop it yourself, or it keeps your Mac awake — and your battery draining — long after the work is done.

The purpose-built option — honest status

What AgentBarista does today for Qwen Code

Straight answer: Qwen Code is in AgentBarista's built-in agent list, so you don't have to add it yourself — the qwen process match is wired in, including the usual npm-install shape, where macOS reports the process as node with the qwen script path in its command line. Because it's a terminal tool, its CPU is trusted: busy above the work threshold (8% by default) counts as real work, with a 90-second grace window (also the default) before we let go. With Accessibility granted we also scan supported terminals for the “to interrupt” status line that CLI agents print while a turn runs. Now the gap, and it's the one that matters: our phrase list for Qwen Code has not been read off a real Qwen Code screen — it's our standard CLI list — and Qwen Code has no session-file signal either (for some agents we watch a file the agent touches while it works; we haven't established one here). So a long model wait at near-zero CPU may not register as work. Keep a manual keep-awake on unattended runs until we've verified it. The process name comes from the project's npm packaging; we haven't run Qwen Code on a Mac of ours at all. And the desktop app is the weaker half — see below.

Recognised out of the box

Qwen Code ships in AgentBarista's agent catalog — no custom setup, including the npm/Node-hosted shape. That part needs no permission.

The gap we'd rather name

No session-file signal, and the phrase list hasn't been checked against a real Qwen Code screen. Busy CPU is covered; a silent model wait may not be. Treat it as unconfirmed, not tested.

Has a safety net regardless

A battery cutoff, plus a one-click restore — it asks for your password once — for the rare case a crash leaves sleep disabled. True for every app AgentBarista watches, verified or not.

The desktop app is a different case

Qwen Code Desktop: recognised, but presence only

Alibaba also ships Qwen Code Desktop, a Mac app. AgentBarista has an entry for it, and it does less than the terminal entry does. That's a deliberate choice, not an oversight.

For a graphical app we don't trust CPU as proof of work. An Electron window redraws, indexes, and animates at percentages that would clear any threshold we could set, so treating that as "the agent is working" would mean holding your Mac awake for as long as the app is open — which is exactly the battery-flattening behavior we're trying to avoid. For this app the work signal has to come from a phrase on screen, because we don't trust a GUI's CPU and it has no session file we can watch. We haven't watched Qwen Code Desktop run a real task on a Mac, so we don't know which phrase it shows while it's busy — and we'd rather ship no guess than a guess that either buys nothing or keeps your Mac awake forever. Its bundle id and app-folder name come from upstream packaging too, so even the "it's running" row is unconfirmed until someone installs it. Either way: no work signal today.

Practical upshot: if you kick off long work from the desktop app and walk away, don't rely on us for it yet — use manual keep-awake for that run, or drive the same job from the CLI, where the CPU signal does work. If you're on the terminal version, the built-in entry is doing its job, with the phrase caveat above.

One more thing about the desktop app that we've allowed for: its bundle carries its own copies of command-line tools inside it, including a codex binary. AgentBarista keys a process to the first .app folder in its path, so the CLI tools bundled inside Qwen Code Desktop are counted as the desktop app, not as separate Codex or Qwen Code CLI rows. Merely opening it adds no stray row.

Qwen Code (built-in list, verification pending) Qwen Code Desktop (recognised, presence only) Claude Code Cursor Codex Gemini CLI Copilot CLI OpenCode Zed Claude ChatGPT + more

Worth saying plainly: free tools like Keepresso and adrafinil are open source and genuinely good, and both read agent hooks, which is a more accurate signal than guessing from CPU. If you're a solo dev running one agent, either is a reasonable choice. Where we put our effort is being quick to support brand-new agents as they ship, and being straight about which ones we've actually measured — which is why this page tells you the desktop app is the weaker half.

It runs on your Mac. AgentBarista never opens your files. To tell a working agent from a finished one it looks at process command lines and CPU, at the names and modification times of your agents' session files, and — only if you grant macOS Accessibility permission — at the on-screen text of the agent apps you enable and of the terminals we support. Two of those can contain your own words: a command line includes any prompt you pass on it, and on-screen text includes whatever is visible in that window, your code included. Both are matched against status phrases on your Mac and discarded on the spot: never stored, never sent. Nothing about your work leaves your Mac — no file contents, no code, no prompts, no file names, no activity data. Your stats and settings stay on this Mac. The app contains no analytics or telemetry of any kind. Its one network call is license validation, sent to our payment provider, Lemon Squeezy: activating a license sends your license key and your Mac's name, and the routine check after that sends your license key and an anonymous instance id — nothing else.

Getting it

Not released yet

AgentBarista for macOS
  • Runs as a menu-bar app — pick a mode, get back to work
  • Battery cutoff on by default (20%), plus a one-click emergency restore
  • Qwen Code is in the built-in agent list
Get notified at launch

Not live yet — leave your email and we'll ping you the moment it is.

Running agents across a team instead? See the teams page.

More agents

Also running Claude Code, Codex CLI, or another agent?

Same Mac-goes-to-sleep problem, different tool. Each of these guides covers the fix for that agent specifically: