[GH-ISSUE #1727] [Feature Request] Native prevent-sleep option during active inference (Windows) #688

Closed
opened 2026-11-04 01:45:06 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Normandanny on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1727

Summary

Please consider adding a native, opt-in "Prevent Sleep" feature to Strata.

The goal is simple:

  • While Strata is actively processing inference requests, prevent Windows from automatically entering sleep mode.
  • Once all requests have finished, restore normal Windows sleep behavior.
  • Allow the system to sleep normally when Strata is running but idle.

Use Case

I run Strata as a local LLM server on a Windows 11 PC, with Hermes Agent running separately on my NAS and sending inference requests over the local network.

I want the PC to sleep automatically when idle to save electricity, while ensuring that long-running inference tasks are never interrupted by Windows automatic sleep.

Currently, this requires either:

  1. Disabling Windows sleep entirely, wasting power.
  2. Using external scripts to monitor Strata and dynamically prevent sleep, adding unnecessary complexity and potential reliability issues.

A native implementation would be much cleaner and more reliable.

Proposed Feature

Add an optional setting, such as:

--prevent-sleep-while-busy

Or a checkbox in the Strata configuration UI:

Prevent system sleep during inference

Expected Behavior

  1. Inference starts: Strata requests the OS to prevent automatic system sleep.
  2. Inference is running: The system stays awake throughout model loading, prompt processing, and token generation.
  3. Inference finishes: Strata releases the sleep-prevention request.
  4. Strata is idle: Windows resumes its normal sleep behavior based on the existing power plan.
  5. Strata exits or crashes: Sleep prevention is automatically released.

The feature should not permanently modify Windows power settings or prevent manually initiated sleep.

Optional: Configurable Idle Grace Period

For AI agent workflows, there may be short gaps between consecutive inference requests while the agent executes tools or processes files.

An optional idle grace period (e.g., 2–5 minutes) would help:

  • Keep the system awake briefly after the last request.
  • Reset the timer whenever a new request arrives.
  • Release sleep prevention once the grace period expires.

This would help avoid unwanted sleep during multi-step agent workflows.

Implementation Suggestion

On Windows, this could use native Windows power management APIs, such as PowerCreateRequest, PowerSetRequest, and PowerClearRequest.

The implementation should account for concurrent requests and reliably release the power request on completion, cancellation, timeout, or shutdown.

Why This Matters

Strata is well suited for running local LLMs as network inference servers.

For users running unattended AI agents or dedicated home LLM servers, this feature would provide:

  • Reliable long-running inference.
  • Lower idle power consumption.
  • No external scripts or workarounds.
  • Better integration with Windows power management.

Windows support alone would already be very useful. Other platforms could be considered later.

Thanks for considering this feature!

Originally created by @Normandanny on GitHub (Oct 9, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1727 ## Summary Please consider adding a native, opt-in "Prevent Sleep" feature to Strata. The goal is simple: - While Strata is actively processing inference requests, prevent Windows from automatically entering sleep mode. - Once all requests have finished, restore normal Windows sleep behavior. - Allow the system to sleep normally when Strata is running but idle. ## Use Case I run Strata as a local LLM server on a Windows 11 PC, with Hermes Agent running separately on my NAS and sending inference requests over the local network. I want the PC to sleep automatically when idle to save electricity, while ensuring that long-running inference tasks are never interrupted by Windows automatic sleep. Currently, this requires either: 1. Disabling Windows sleep entirely, wasting power. 2. Using external scripts to monitor Strata and dynamically prevent sleep, adding unnecessary complexity and potential reliability issues. A native implementation would be much cleaner and more reliable. ## Proposed Feature Add an optional setting, such as: `--prevent-sleep-while-busy` Or a checkbox in the Strata configuration UI: `Prevent system sleep during inference` ### Expected Behavior 1. **Inference starts:** Strata requests the OS to prevent automatic system sleep. 2. **Inference is running:** The system stays awake throughout model loading, prompt processing, and token generation. 3. **Inference finishes:** Strata releases the sleep-prevention request. 4. **Strata is idle:** Windows resumes its normal sleep behavior based on the existing power plan. 5. **Strata exits or crashes:** Sleep prevention is automatically released. The feature should not permanently modify Windows power settings or prevent manually initiated sleep. ## Optional: Configurable Idle Grace Period For AI agent workflows, there may be short gaps between consecutive inference requests while the agent executes tools or processes files. An optional idle grace period (e.g., 2–5 minutes) would help: - Keep the system awake briefly after the last request. - Reset the timer whenever a new request arrives. - Release sleep prevention once the grace period expires. This would help avoid unwanted sleep during multi-step agent workflows. ## Implementation Suggestion On Windows, this could use native Windows power management APIs, such as `PowerCreateRequest`, `PowerSetRequest`, and `PowerClearRequest`. The implementation should account for concurrent requests and reliably release the power request on completion, cancellation, timeout, or shutdown. ## Why This Matters Strata is well suited for running local LLMs as network inference servers. For users running unattended AI agents or dedicated home LLM servers, this feature would provide: - Reliable long-running inference. - Lower idle power consumption. - No external scripts or workarounds. - Better integration with Windows power management. Windows support alone would already be very useful. Other platforms could be considered later. Thanks for considering this feature!
Author
Owner

@Niko1221 commented on GitHub (Oct 10, 2026):

Thank you, this is in v0.1.42 as a run-config key (opt-in, default off): "prevent_sleep": true in strata-.json. While at least one request is running or queued, the server keeps Windows awake (SetThreadExecutionState with ES_SYSTEM_REQUIRED, not the display); when it is idle, and when it exits, normal sleep rules are back, so the PC can still sleep between jobs. It does nothing on Linux. It has unit tests with the Windows call mocked, and it was also run on a Windows PC before the release.

<!-- gh-comment-id:6099718581 --> @Niko1221 commented on GitHub (Oct 10, 2026): Thank you, this is in v0.1.42 as a run-config key (opt-in, default off): "prevent_sleep": true in strata-<model>.json. While at least one request is running or queued, the server keeps Windows awake (SetThreadExecutionState with ES_SYSTEM_REQUIRED, not the display); when it is idle, and when it exits, normal sleep rules are back, so the PC can still sleep between jobs. It does nothing on Linux. It has unit tests with the Windows call mocked, and it was also run on a Windows PC before the release.
Author
Owner

@Normandanny commented on GitHub (Oct 10, 2026):

Thank you Niko being so responsive!

<!-- gh-comment-id:6099772551 --> @Normandanny commented on GitHub (Oct 10, 2026): Thank you Niko being so responsive!
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6156191640 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#688
No description provided.