Skip to content

/keep-alive in WSL2 does not prevent the Windows host from sleeping #5304

Open

Description

@heaths

Describe the bug

When Copilot CLI runs inside WSL2, /keep-alive does not prevent the Windows host from sleeping. WSL is treated as Linux, so the CLI attempts to use systemd-inhibit; that does not create a Windows host power request visible through powercfg -requests.

This means long-running Copilot tasks can be suspended when the Windows host sleeps, even though keep-alive is enabled.

Affected version

1.0.105

Steps to reproduce the behavior

  1. Run Copilot CLI inside WSL2 on Windows.
  2. Enable /keep-alive on or the busy-mode equivalent.
  3. From Windows, run powercfg -requests.
  4. Observe that Copilot CLI has not registered a Windows host power request.
  5. Allow the Windows host's configured idle timeout to expire.
  6. Observe that the host can sleep and suspend the WSL2/Copilot workload.

Expected behavior

Enabling /keep-alive inside WSL2 should prevent the Windows host from sleeping, just as running Copilot CLI natively on Windows does.

The implementation could detect WSL2 and invoke an appropriate Windows-host mechanism, or clearly expose a supported integration that creates and releases the host power request for the lifetime of the Copilot task.

Additional context

The original implementation uses systemd-inhibit on Linux and Windows power APIs only for native Windows processes:
https://github.com/github/copilot-agent-runtime/pull/5669

A later fix explicitly handles WSL as an environment where the Linux inhibitor may fail, but does not forward sleep inhibition to the Windows host:
https://github.com/github/copilot-agent-runtime/pull/13161

WSL2 is important for file-heavy Rust, Go, and similar development because working on its Linux filesystem can be substantially faster than working directly on NTFS. Requiring a separate Windows keep-awake utility makes /keep-alive ineffective for this common workflow.

Originating discussion:
https://github.slack.com/archives/C093WSH3L8J/p1793378606869279

Activity

  1. added theissue type on Oct 30, 2026
  2. heaths commented on Oct 30, 2026

    @heaths
    Author

    Likely something that will best to be done in WSL itself: microsoft/WSL#42121; however, Copilot CLI could ship a small executable that basically does nothing more than below when running under WSL (various easy ways to detect) in addition to calling org.freedesktop.login1.Manager.Inhibit():

    #include <windows.h>
    #include <conio.h>
    
    int main() {
      SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
    
      _cputs("Press any key to exit...");
      _getch();
    
      return 0;
    }

    Preventing shutdown isn't entirely possible—much like with systemd—and methods to "discourage" it are far more involved, but disabling the idle timer this way would accomplish most of the same goals. It's at least analogous to the CLI setting just "idle" as the inhibitor now.

  3. added
    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal
    and removed on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions