hermes - ✅(Solved) Fix claw cleanup falsely detects OpenClaw as running because it uses 'pgrep -f openclaw' [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#12648Fetched 2026-04-20 12:17:42
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Error Message

Cleanup should warn only when an actual OpenClaw process is running.

Root Cause

Bug Description

hermes claw cleanup can abort even when no real OpenClaw daemon is running, because _detect_openclaw_processes() uses pgrep -f openclaw on non-Windows systems.

Fix Action

Fixed

PR fix notes

PR #12691: fix(claw): avoid false positive matching pgrep -f openclaw

Description (problem / solution / changelog)

Fixes #12648. Uses bounded regex matching for pgrep to avoid catching python/node wrappers testing the claw.

Changed files

  • hermes_cli/claw.py (modified, +11/-2)
  • tests/hermes_cli/test_claw.py (modified, +3/-2)

Code Example

source venv/bin/activate
pytest -q tests/hermes_cli/test_claw.py -q

---

pgrep -fal openclaw
RAW_BUFFERClick to expand / collapse

Bug Description

hermes claw cleanup can abort even when no real OpenClaw daemon is running, because _detect_openclaw_processes() uses pgrep -f openclaw on non-Windows systems.

Affected files / lines

  • hermes_cli/claw.py:103-110
  • Symptoms currently surface in tests/hermes_cli/test_claw.py:505, :540, :568

Why this is a bug

pgrep -f matches the entire command line, not just the executable name. Any unrelated process whose argv contains the string openclaw will be treated as a running OpenClaw process.

In the Hermes test/runtime environment, even the shell command used to check for openclaw can match itself, so cleanup warns/aborts incorrectly.

Minimal reproduction / evidence

1) Targeted tests currently fail on default branch

source venv/bin/activate
pytest -q tests/hermes_cli/test_claw.py -q

Observed failures:

  • TestCmdCleanup::test_dry_run_lists_dirs
  • TestCmdCleanup::test_shows_workspace_details
  • TestCmdCleanup::test_skips_when_user_declines

All three fail because cleanup prints the "OpenClaw is still running" warning path and aborts before normal cleanup output.

2) pgrep -f matches the checking shell itself

pgrep -fal openclaw

Example output from this repo environment included the current shell command because its argv contained openclaw.

Expected Behavior

Cleanup should warn only when an actual OpenClaw process is running.

Actual Behavior

Cleanup can abort in dry-run and non-interactive flows due to false positives from command-line substring matching.

Suggested investigation direction

  • Avoid pgrep -f openclaw substring matching.
  • Match a stricter process name / executable pattern.
  • Consider excluding the current process and shell wrappers.
  • Add a regression test that simulates an argv containing openclaw without a real OpenClaw daemon.

extent analysis

TL;DR

Modify the _detect_openclaw_processes() function to use a more specific process matching method instead of pgrep -f openclaw to avoid false positives.

Guidance

  • Investigate using pgrep with the -x option to match the exact process name instead of a substring, if the OpenClaw daemon has a unique executable name.
  • Consider using a more robust process detection method, such as checking for a specific process ID or executable path.
  • Add a check to exclude the current process and shell wrappers from the process list to prevent self-matching.
  • Create a regression test to simulate a process with openclaw in its argv without a real OpenClaw daemon to ensure the fix is effective.

Example

import subprocess

def _detect_openclaw_processes():
    # Replace this line with a more specific process matching method
    # processes = subprocess.check_output(['pgrep', '-f', 'openclaw']).decode().strip()
    processes = subprocess.check_output(['pgrep', '-x', 'openclaw']).decode().strip()
    # Additional processing to exclude the current process and shell wrappers
    # ...

Notes

The solution may require modifications to the hermes_cli/claw.py file, specifically the _detect_openclaw_processes() function. The exact changes will depend on the available process detection methods and the specific requirements of the OpenClaw daemon.

Recommendation

Apply a workaround by modifying the _detect_openclaw_processes() function to use a more specific process matching method, such as pgrep -x openclaw, to reduce false positives. This change should be made in the hermes_cli/claw.py file.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING