Gateway process detection falsely matches CLI ancestor PIDs
NousResearch/hermes-agent · cluster 13242
Data as of
Nothing open on GitHub. Fix merged in #19586. Check it covers your case.
The short answer
- Known?
- Yes. 6 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #19586. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
resolved, deciding PR #19586. That is separate from the fix event. - Still open
- Nothing open on GitHub.
These issues and PRs address a bug where the gateway's running-instance detection incorrectly identifies the invoking CLI process (or its ancestor chain) as an already-running gateway. Multiple fix approaches target PID scanning logic to exclude ancestor processes.
Open issues0
Open PRs0
Fixes on record
-
#19586 fix(gateway): exclude ancestor PIDs from gateway process scan
files:
hermes_cli/gateway.pyShow the diff
-
hermes_cli/gateway.py@@ -237,6 +237,26 @@ def _graceful_restart_via_sigusr1(pid: int, drain_timeout: float) -> bool: return False +def _get_ancestor_pids() -> set[int]: + """Return the set of PIDs in the current process's ancestor chain. + + Walks from the current PID up to PID 1 (init) so that process-table scans + never match the calling CLI process or any of its parents. This prevents + ``hermes gateway status`` from falsely counting the ``hermes`` CLI that + invoked it as a running gateway instance (see #13242). + """ + ancestors: set[int] = set() + pid = os.getpid() + # Cap iterations to avoid infinite loops on exotic platforms. + for _ in range(64): + ancestors.add(pid) + parent = _get_parent_pid(pid) + if parent is None or parent <= 0 or parent in ancestors: + break + pid = parent + return ancestors + + def _append_unique_pid(pids: list[int], pid: int | None, exclude_pids: set[int]) -> None: if pid is None or pid <= 0: return @@ -252,6 +272,10 @@ def _scan_gateway_pids(exclude_pids: set[int], all_profiles: bool = False) -> li a live gateway when the PID file is stale/missing, and ``--all`` sweeps can discover gateways outside the current profile. """ + # Exclude the entire ancestor chain so the CLI process that invoked this + # scan (e.g. ``hermes gateway status``) is never mistaken for a running + # gateway. See #13242. + exclude_pids = exclude_pids | _get_ancestor_pids() pids: list[int] = [] patterns = [ "hermes_cli.main gateway",
-
4 PRs closed without merging
From the close comments: stale or abandoned 2 · closed without comment 1 · merged via another change 1
- #13250 fix(gateway): exclude CLI invocations from _looks_like_gateway_process (Closes #13242) · closed without comment
- #13273 fix(gateway): exclude CLI invoker ancestor chain in _append_unique_pid · stale or abandoned
- #14177 fix(gateway): ignore invoking CLI ancestor during PID scan · stale or abandoned
-
#19146 fix: exclude ancestor PIDs from gateway process scan (#13242) · merged via another change →
#19586
Closed issues · 1
- Closed#13242gateway run detects calling CLI process as running gateway instance (self false positive)
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.33: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Merged PRs
- #19586
- Closed issues
- 1
- Attempts
- 4 PRs closed without merging
- Fix link checked
- 4 May 2026