# NousResearch/hermes-agent · Gateway process detection and restart corrections

## Open now

- Nothing open on GitHub.

These items address bugs where the gateway's --replace and restart logic could not detect script-style gateway processes, potentially allowing duplicate instances and missed shutdowns, with additional corrections for silent outages on Windows.

## TL;DR

- 3 member(s): 0 open issue(s), 1 closed issue(s), 0 open PR(s), 1 merged PR(s), 1 PR(s) closed without merging.
- A fix was merged to main in PR #1908. Verify it addresses your case.
- **Recommended:** read PR #1908 (and any competing PRs below) before filing. Confirm the merged change covers your symptom.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `resolved` · deciding PR(s): `pr-1908`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_SPANNING`): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
- Pairwise link density `0.67`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Closed / duplicate issues

- #1830: \[Bug\]: gateway --replace can miss existing script-style gateway processes, allowing duplicate instances and duplicate Discord replies

## Prior & competing PRs

- **#1908: fix(gateway): detect script-style gateway processes for --replace**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `gateway/status.py`, `hermes_cli/gateway.py`, `tests/gateway/test_status.py`
  - fix hunks:
  - `gateway/status.py`

    ```diff
    @@ -87,6 +87,7 @@ def _looks_like_gateway_process(pid: int) -> bool:
     
         patterns = (
             "hermes_cli.main gateway",
    +        "hermes_cli/main.py gateway",
             "hermes gateway",
             "gateway/run.py",
         )
    ```

    ```diff
    @@ -105,6 +106,7 @@ def _record_looks_like_gateway(record: dict[str, Any]) -> bool:
         cmdline = " ".join(str(part) for part in argv)
         patterns = (
             "hermes_cli.main gateway",
    +        "hermes_cli/main.py gateway",
             "hermes gateway",
             "gateway/run.py",
         )
    ```
  - `hermes_cli/gateway.py`

    ```diff
    @@ -31,6 +31,7 @@ def find_gateway_pids() -> list:
         pids = []
         patterns = [
             "hermes_cli.main gateway",
    +        "hermes_cli/main.py gateway",
             "hermes gateway",
             "gateway/run.py",
         ]
    ```
  - `tests/gateway/test_status.py`

    ```diff
    @@ -42,6 +42,26 @@ def test_get_running_pid_accepts_gateway_metadata_when_cmdline_unavailable(self,
     
             assert status.get_running_pid() == os.getpid()
     
    +    def test_get_running_pid_accepts_script_style_gateway_cmdline(self, tmp_path, monkeypatch):
    +        monkeypatch.setenv("HERMES_HOME", str(tmp_path))
    +        pid_path = tmp_path / "gateway.pid"
    +        pid_path.write_text(json.dumps({
    +            "pid": os.getpid(),
    +            "kind": "hermes-gateway",
    +            "argv": ["/venv/bin/python", "/repo/hermes_cli/main.py", "gateway", "run", "--replace"],
    +            "start_time": 123,
    +        }))
    +
    +        monkeypatch.setattr(status.os, "kill", lambda pid, sig: None)
    +        monkeypatch.setattr(status, "_get_process_start_time", lambda pid: 123)
    +        monkeypatch.setattr(
    +            status,
    +            "_read_process_cmdline",
    +            lambda pid: "/venv/bin/python /repo/hermes_cli/main.py gateway run --replace",
    +        )
    +
    +        assert status.get_running_pid() == os.getpid()
    +
     
     class TestGatewayRuntimeStatus:
         def test_write_runtime_status_overwrites_stale_pid_on_restart(self, tmp_path, monkeypatch):
    ```
- **#1831: fix(gateway): detect script-style gateway processes for --replace**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`; refs `#1908`

## Fix status

- Merged to main in PR #1908 (cited above). No release data is tracked. Verify downstream.
- Fix last verified (merged) `2026-03-18`. This confirmation is old and may be out of date (a revert/reopen would not have invalidated it here); re-verify.
- Subsystem: `gateway`
