fix: use ps without environment for gateway scan#9100
Open
corazzione wants to merge 1 commit into
Open
Conversation
1 task
|
Using |
IISweetHeartII
added a commit
to IISweetHeartII/hermes-agent
that referenced
this pull request
Apr 16, 2026
Two issues prevent `find_gateway_pids()` from detecting the running
gateway process on macOS, causing `hermes cron status` to falsely
report "Gateway is not running" even when the process is alive and
healthy.
**1. `launchctl list <label>` output format mismatch**
Modern macOS (12+) returns a property-list dictionary format:
"PID" = 12345;
The existing parser expected the legacy tabular format:
PID Status Label
Added regex-based extraction for the modern dict format with a
fallback to the legacy tabular parser.
Refs: NousResearch#4820
**2. `ps` flag argument splitting**
`subprocess.run(["ps", "-A", "eww", ...])` passes `eww` as a
separate argument, which BSD `ps` interprets as a process name
filter rather than flags. This returns ~5 results instead of the
full process list (~400+), causing pattern matching to miss the
gateway process.
Fixed by combining flags: `["ps", "-Aeww", ...]`
Refs: NousResearch#9069, NousResearch#9100
Tested on macOS 15.4 (Sequoia) with launchd-managed gateway.
Before: `hermes cron status` → "Gateway is not running"
After: `hermes cron status` → "Gateway is running — PID: <pid>"
5 tasks
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ps wwfor Unix gateway process discovery so the command column does not include environment variables.Root cause
On FreeBSD,
ps eww -ax -o pid=,command=prefixes the command column with the process environment. That can prevent the gateway command patterns from matching reliably, sohermes cron listandhermes cron statusmay warn that the gateway is not running even when it is active.Changes
eflag from the Unixpsinvocation while keeping wide output.Validation
python -m pytest tests/hermes_cli/test_update_gateway_restart.py::TestFindGatewayPidsExclude::test_unix_process_scan_does_not_include_environment -q -n0(failed before the code change, passed after)python -m pytest tests/hermes_cli/test_update_gateway_restart.py::TestFindGatewayPidsExclude -q -n0python -m py_compile hermes_cli/gateway.py tests/hermes_cli/test_update_gateway_restart.pygit diff --checkI also ran
python -m pytest tests/hermes_cli/test_update_gateway_restart.py -q -n0; unrelated Windows-local failures remain in existing launchd/POSIX PATH tests.Fixes #9069