Stale PID and argv in gateway_state.json

NousResearch/hermes-agent · cluster 1631 · gateway

Data as of

Nothing open on GitHub. Fix merged in #22674. Check it covers your case.

The short answer

0open issues
0open PRs
4items grouped
Known?
Yes. 4 related items grouped here, 2 issues already closed.
Fix event
A fix was merged to main in PR #22674. Check it covers your case. No release data is tracked.
Tracker
The maintainers' tracker marks this partially resolved, deciding PR #22674. That is separate from the fix event.
Still open
Nothing open on GitHub.

These issues and fixes address gateway_state.json retaining outdated PID and argv metadata after gateway restarts or binary path changes. The associated fixes aim to refresh that runtime metadata on each status write.

Open issues0

No open issues.

Open PRs0

No open pull requests.

Fixes on record

Merged to main. A stamp counts the issues a fix is linked to.

  • #22674 fix(gateway): refresh runtime argv metadata on every status write (salvage #22579)

    merged to main

    files: gateway/status.py, tests/gateway/test_status.py

    Show the diff
    • gateway/status.py
      @@ -482,10 +482,12 @@ def write_runtime_status(
           """Persist gateway runtime health information for diagnostics/status."""
           path = _get_runtime_status_path()
           payload = _read_json_file(path) or _build_runtime_status_record()
      +    current_record = _build_pid_record()
           payload.setdefault("platforms", {})
      -    payload.setdefault("kind", _GATEWAY_KIND)
      -    payload["pid"] = os.getpid()
      -    payload["start_time"] = _get_process_start_time(os.getpid())
      +    payload["kind"] = current_record["kind"]
      +    payload["pid"] = current_record["pid"]
      +    payload["argv"] = current_record["argv"]
      +    payload["start_time"] = current_record["start_time"]
           payload["updated_at"] = _utc_now_iso()
       
           if gateway_state is not _UNSET:
    • tests/gateway/test_status.py
      @@ -287,6 +287,30 @@ def test_write_runtime_status_overwrites_stale_pid_on_restart(self, tmp_path, mo
               assert payload["pid"] == os.getpid(), "PID should be overwritten, not preserved via setdefault"
               assert payload["start_time"] != 1000.0, "start_time should be overwritten on restart"
       
      +    def test_write_runtime_status_overwrites_stale_argv_on_restart(self, tmp_path, monkeypatch):
      +        """Regression: gateway_state.json must not keep the previous launch argv."""
      +        monkeypatch.setenv("HERMES_HOME", str(tmp_path))
      +
      +        state_path = tmp_path / "gateway_state.json"
      +        state_path.write_text(json.dumps({
      +            "pid": 99999,
      +            "start_time": 1000.0,
      +            "kind": "hermes-gateway",
      +            "argv": ["/old/path/hermes", "gateway", "run"],
      +            "platforms": {},
      +            "updated_at": "2025-01-01T00:00:00Z",
      +        }))
      +
      +        monkeypatch.setattr(status.sys, "argv", ["/new/path/hermes", "gateway", "run"])
      +        monkeypatch.setattr(status, "_get_process_start_time", lambda pid: 2000)
      +
      +        status.write_runtime_status(gateway_state="running")
      +
      +        payload = status.read_runtime_status()
      +        assert payload["argv"] == ["/new/path/hermes", "gateway", "run"]
      +        assert payload["pid"] == os.getpid()
      +        assert payload["start_time"] == 2000
      +
           def test_write_runtime_status_records_platform_failure(self, tmp_path, monkeypatch):
               monkeypatch.setenv("HERMES_HOME", str(tmp_path))
       

1 PR closed without merging

From the close comments: merged via another change 1

  • #22579 fix(gateway): refresh runtime argv metadata · merged via another change → #22674
Closed issues · 2
  • Closed#1631[Bug]: gateway_state.json retains stale PID after gateway restart
  • Closed#22560[Bug]: gateway_state.json reports stale argv after upstream binary path changes
How this cluster was grouped
  • Link evidence (partly structural links): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text.
  • Members outside that structural core may belong to a different underlying problem.
  • Pairwise link density 0.39: the share of item 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.

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 Lab

At a glance

Subsystem
gateway
Merged PRs
#22674
Closed issues
2
Attempts
1 PR closed without merging
Fix link checked
9 May 2026

For your agent

The same facts, typed.