Skip to content

Keep awake while local agents work - #1490

Draft
delkc wants to merge 6 commits into
mainfrom
clay/agent-keep-awake
Draft

delkc wants to merge 6 commits into
mainfrom
clay/agent-keep-awake

Conversation

@delkc

@delkc delkc commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Why

This brings the keep-awake preference into the new Settings structure. It’s another piece of the work across buzz-app to give settings clearer homes and bring over capabilities we’re still missing.

Local agents need this computer awake to keep working, but that shouldn’t mean keeping the display on or preventing sleep just because an agent is enabled.

What

  • Add Keep awake while local agents work under Buzz → Agent setup → Agent behavior, alongside Remember mentioned agents.
  • Keep it off by default and save the choice on this device. It’s available on macOS desktop; other platforms show it as unavailable.
  • Use the description: “Prevent automatic sleep while local agents work on this computer. Displays can still sleep.”

How

The preference follows actual local agent work across communities, not the Agent Activity plugin or idle harness processes. Codex stays covered through the end of its turn, even if it’s already posted its final reply.

Pi’s recovered turns also need their own execution accounting. Each recovered turn stays covered after its triggering mention or session control finishes. Harness steps renew that demand; settlement, runtime removal, and custody loss release it.

Sleep prevention ends when work finishes, the preference is turned off, or Buzz releases the agent, reloads, or quits. A native safety cap also releases it after an hour without agent activity. New activity can resume it, and failures have an explicit Retry.

Risk

Keeping the computer awake can use more battery. This prevents automatic idle sleep—not lid-close sleep, explicit Sleep, or sleep forced by a managed-device policy.

The change touches shared agent execution and native power management. The native host trusts work reported by the main app window; it doesn’t independently monitor agent processes.

Testing

Earlier testing checked placement and copy in the native dev app with the existing identity. The latest posted review then found a gap for recovered Pi turns.

Follow-up commits 4764774be and 6296b2ba6 address that gap and the two failed browser journeys. Head b7bae8bf6 included them and the main base used for hardware acceptance, without rewritten history. A dependency-only follow-up at 8de82ea68 cherry-picks the upstream Tokio 1.53.3 fix (#1581); no application source or policy exception changed. Required pre-push hooks passed, including related tests, design checks, and workspace Clippy. A bounded independent source review found no blockers in either fix. The Pi regression failed before the fix for both mention and Compact triggers, then passed after it.

On hardware-acceptance head b7bae8bf6, bin/cargo test --locked -p buzz-foundation --lib keep_awake::tests passed with a real macOS sleep-prevention assertion and a controlled-clock one-hour cap. The native command-isolation test passed too. We didn’t change the machine’s sleep settings or wait an hour.

No browser journeys were added or removed. The member geometry test now waits for the dialog’s entrance animation before recording exact bounds. The thread-tab journey uses the existing keyboard context-menu action instead of an unstable pointer setup. Its menu, preview dismissal, navigation, and focus-return assertions remain. Existing native right-click coverage in external-links.spec.mjs and pointer/scroll preview journeys remain unchanged; this tab journey no longer tests right-click on an internal preview link.

On hardware-acceptance head b7bae8bf6, both affected full browser files passed locally in Chromium and WebKit: 50 cases on Apple Silicon macOS with Playwright 1.63.0, two workers, and screenshot/trace capture off. This took about 2.5 minutes wall time and 233 seconds of summed test execution while native compilation also ran. The slowest case was the Chromium link-navigation journey at 16.5 seconds. An earlier pre-merge run took 1.5 minutes; these were not isolated timing comparisons. The original Linux CI failures were not reproduced locally, so this is not hosted fail-then-pass evidence or a performance improvement claim.

This uses the shared SettingsGroup, SwitchPreferenceRow, Button, and ToastNotice, with no new design-system styles or variants.

Native dev build b7bae8bf6 was exercised with the development broker and native-MCP bridge disabled. The existing native identity and community loaded. In Agent setup, enabling keep-awake while idle showed “Waiting for local agent work.” pmset -g assertions showed no assertion owned by Buzz, as expected. The preference was restored to off. No identity, membership, or relay data was changed for this check.

Clay completed the real-hardware test with Juniper on native dev head b7bae8bf6; full results. On battery with a one-minute system sleep timer, the display slept for about six minutes while Buzz held the sole idle-system-sleep assertion. No system sleep event occurred, and once-a-minute tool activity and samples continued. Buzz released the same assertion at turn completion. The AC run separately confirmed acquisition and release but did not establish sleep prevention because system sleep was disabled on AC. The managed Mac had no energy/power policy applied; this does not establish behavior under a forced-sleep policy.

The one-hour wall-clock inactivity test is intentionally skipped by the human author; the controlled-clock native test covers the cap. No hour-long manual test is required for this review round.

Earlier hosted CI passed JavaScript, browser, measurement, security, and DCO checks. Rust attempt 1 timed out during Ubuntu downloads; attempt 2 rejected inherited Tokio 1.53.1 under RUSTSEC-2026-0386 before lint or tests. Follow-up 8de82ea68 applies main’s Tokio 1.53.3 fix (#1581). Local dependency policy, real-assertion/controlled-clock cap, and command-isolation tests pass on that head, with no advisory exception or bypass. Independent review of the two-line lockfile change found no blockers. Current-head CI passed at 8de82ea68, including dependency policy, Rust/Node integration, all JavaScript and browser lanes, measurements, and both required checks (CI required and DCO Check). Juniper’s hardware result above applies to b7bae8bf6; it has not been repeated after the dependency update.

A bounded source review of the main merge found no new integration blockers. Remaining manual gaps: preference-off control run; release on toggle-off during work, Reload, and Quit; Codex/Pi real-provider and recovered-Pi paths; both themes, narrow widths/enlarged text, and keyboard/error states. Core Claude/display-off human acceptance is confirmed, but these gaps are not marked complete. This stays draft pending the remaining readiness checks. The review-completion attestation is not claimed.

Bigger picture

This follows the Settings reorganization (#1248) and community-local settings (#1363). We’re keeping this piece focused: no changes to agent defaults, harness defaults, provider scoping, or links to those controls.

Generated with Goose

@delkc
delkc marked this pull request as ready for review October 21, 2026 19:40
@delkc
delkc requested review from a team as code owners October 21, 2026 19:40

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord’s automated source review via Wes’s account, integrating independent Rocket (systems/lifecycle), Mantis (correctness/security/concurrency), and Groot (product/accessibility) reviews.

No actionable findings. Source assessment: 9/10 for minimalness, elegance and correctness within this review’s scope.

Reviewed head 3fcd963 against base 3d26215. Traced native assertion/lease/timer cleanup, runner execution holds and Codex completion, preference persistence, unsupported platforms, failure/retry paths, shared settings controls and changed regression tests. The PR description and both commit messages were also inspected; no images were attached and no public-material disclosure finding was identified.

Validation limits: source-only; no tests, builds or app execution, and CI was not assessed. Real IOKit/laptop sleep and App Nap behavior, packaged lifecycle, rendered retry-focus/accessibility behavior, both themes/enlarged text, and human acceptance remain unverified. The PR description’s outstanding rebased-build acceptance checks remain outstanding; this comment is not an approval or merge authorization.

delkc and others added 2 commits October 22, 2026 09:18
Add an off-by-default macOS idle-sleep preference tied to actual local
agent execution, with a native inactivity cap and explicit recovery.
Preserve display sleep and keep Codex execution distinct from reply display.

Co-authored-by: Goose <goose@aaif.io>
Signed-off-by: Clay Delk <clay.delk@gmail.com>
Keep the shared Agents power service outside the login fixture's
native-call assertions without weakening its authentication checks.

Co-authored-by: Goose <goose@aaif.io>
Signed-off-by: Clay Delk <clay.delk@gmail.com>
@delkc
delkc force-pushed the clay/agent-keep-awake branch from 3fcd963 to 83c74bb Compare October 22, 2026 14:07

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord’s automated source review via Wes’s account, integrating independent Rocket (systems/lifecycle), Mantis (correctness/security/concurrency), and Groot (product/accessibility) lanes.

One P2 integration defect: recovered Pi turns can outlive all tracked keep-awake demand (inline). Source assessment: 8/10 until recovered work participates in execution accounting.

Reviewed head 83c74bb against base 3d23acb. Compared with the previously reviewed 3fcd963: the keep-awake patch changes only where it integrates with the Decisions classifier/native host, and the Builderlab test patch is unchanged. Checked classifier success/failure/deadline release, native registration/reset, and the newly merged Pi producer’s normal handoff, standalone turns and recovery of unfinished turns. Preference UI and recovery paths retain their prior implementation. The public PR description and both commit messages contain no identified disclosure issue; no images are attached.

Validation limits: source-only; no tests, builds or app execution. Colocated regression coverage remains appropriate; no browser cases were added or removed, and reported test results were not reproduced. A single hosted-check snapshot at 14:14 UTC showed CI still running/queued, with Windows validation skipped. Real macOS sleep/App Nap behavior, packaged lifecycle, rendered retry-focus/accessibility behavior, themes/enlarged text and human acceptance remain unverified. This COMMENT is not approval or merge authorization.

Comment thread src/features/agents/runner.ts
@delkc
delkc marked this pull request as draft October 23, 2026 13:27
delkc and others added 3 commits October 23, 2026 09:38
Keep recovered waits under the runner’s existing lifetime and custody
fences, independent of the delivery or session control that found them.
Renew demand on harness steps and release it on settlement or retirement.

Co-authored-by: Goose <goose@aaif.io>
Signed-off-by: Clay Delk <clay.delk@gmail.com>
Record member bounds after the dialog’s entrance animations finish.
Use the existing keyboard menu path for the thread-tab action journey,
which does not assert pointer hit-testing during Virtua’s scroll hold.
Keep exact geometry assertions and all browser cases unchanged.

Co-authored-by: Goose <goose@aaif.io>
Signed-off-by: Clay Delk <clay.delk@gmail.com>
Include current Settings, browser, and Builderlab updates in the build
used for validation without rewriting the reviewed feature history.

Co-authored-by: Goose <goose@aaif.io>
Signed-off-by: Clay Delk <clay.delk@gmail.com>
@delkc

delkc commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Real-hardware sleep test results (from Clay's AI agent)

Setup: native dev build at b7bae8bf6, macOS, with Keep awake while local agents work on. The work was a local agent turn (Claude Code through Buzz) that stayed active with lightweight tool calls once a minute. Evidence comes from pmset -g assertions, sampled every minute, and pmset -g log. This is a managed Mac. MDM sets only the screen saver (5 min, then lock). No energy or power profile is applied. System sleep settings weren't changed.

Run 1: on AC power, 11:10–11:25 ET

  • buzz-foundation held one PreventUserIdleSystemSleep "Buzz — local agents are working" assertion from turn start to turn end. It released at 11:25:57, as soon as the turn ended, after being held for 15:58.
  • This run didn't test sleep prevention. On AC power, system sleep is 0 (never), and the display never turned off. At 5 minutes the screen saver locked the screen, which isn't display sleep. The only other hold was powerd's "Prevent sleep while display is on".

Run 2: on battery, 11:31–11:46 ET (system sleep 1 min, display sleep 5 min)

  • 11:31: the Buzz assertion was active. A short Contacts sync hold was gone by 11:32.
  • 11:36:02: the display turned off, and powerd released "Prevent sleep while display is on". From then on, Buzz's assertion was the only thing preventing idle sleep.
  • 11:36:02–11:41:55: the display was off for about 6 minutes against the 1-minute system sleep timer. There's no sleep event in pmset -g log, and the once-a-minute samples kept running the whole time.
  • About 11:42: back on AC power.
  • 11:46:27: the assertion released at turn end, after being held for 15:34. It had the same ID the whole time, with no break.

Not covered

  • A control run with the preference off. On battery with the display off, the Mac should sleep after about a minute, which would confirm Buzz was the deciding hold.
  • The one-hour inactivity cap on real hardware. That's covered only by the controlled-clock native test.
  • Release on toggle-off mid-turn, on Reload and on Quit.
  • Codex and Pi turns, and the recovered Pi turn path.
  • The UI checks: both themes, narrow widths and enlarged text, and keyboard use.

Signed-off-by: John Tennant <jtennant@block.xyz>
Co-authored-by: Oliver <e78152627ea32fbacb070e5047afcfb8e409fa3343d9e618227baacca5b5e607@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 6fc1d18)
Signed-off-by: Clay Delk <clay.delk@gmail.com>
Co-authored-by: Goose <goose@aaif.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants