hermes - ✅(Solved) Fix [Bug]: `_reap_orphaned_browser_sessions()` glob pattern doesn't match actual socket directories, causing daemon startup failure [2 pull requests]

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…

Error Message

Additional Logs / Traceback (optional)

Root Cause

  1. On startup/cleanup, orphan reaping should detect and terminate orphaned agent-browser sessions regardless of naming prefix (h_, cdp_, hermes_, etc).
  2. Old cloud-session daemons should not accumulate across crashes/restarts.
  3. Browser navigation should remain stable without socket errors caused by stale daemons.

Fix Action

Fixed

PR fix notes

PR #13084: fix(tools): reap orphaned cloud browser daemons with hermes session p…

Description (problem / solution / changelog)

What does this PR do?

This PR fixes orphan browser daemon cleanup for cloud sessions.

Problem: Cloud browser providers create session directories with the hermes_ prefix (for example, agent-browser-hermes_...). The orphan reaper only scanned h_ and cdp_ prefixes, so hermes_ orphan sessions were skipped after unclean exits.

Impact: Skipped cleanup can leave many stale agent-browser node daemons running over time, which may contribute to socket and stability issues in later browser runs.

Why this approach: This is a minimal, low-risk bug fix. It extends the existing glob-based discovery by adding hermes_ to the scan list, while keeping all current ownership and pid safety checks unchanged.

Related Issue

Fixes https://github.com/NousResearch/hermes-agent/issues/13081

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Updated orphan session discovery in browser_tool.py to include cloud-prefixed session directories:
  • existing: agent-browser-h_*
  • existing: agent-browser-cdp_*
  • added: agent-browser-hermes_*
  • Kept all existing owner_pid and daemon pid liveness checks unchanged.
  • No behavior changes outside orphan discovery scope.

How to Test

  1. Configure browser cloud provider to browser-use (or another cloud backend that creates hermes_ session names).
  2. Trigger browser navigation, then force an unclean process exit. Repeat a few times to create potential orphan sessions.
  3. Restart Hermes and trigger browser usage again. Verify hermes_ orphan directories are now discovered by the reaper and stale daemons are cleaned up.
  4. Run targeted test command: run_tests.sh test_browser_cdp_tool.py
  5. Confirm result: 19 passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Notes: I ran focused tests via the project test wrapper: run_tests.sh test_browser_cdp_tool.py Result: 19 passed.

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Focused test run output:

  • run_tests.sh test_browser_cdp_tool.py
  • 19 passed in about 10 seconds

Changed files

  • tools/browser_tool.py (modified, +2/-0)

PR #13155: fix(tools): reap orphaned cloud browser daemons with hermes session prefix

Description (problem / solution / changelog)

Summary

Salvage of #13084 by @AllardQuek — cherry-picked onto current main.

Cloud browser providers (Browserbase, Browser Use, Firecrawl) create session dirs with hermes_ prefix, but the orphan reaper only scanned h_* and cdp_*. Stale cloud daemons were never cleaned up.

Changes

  • tools/browser_tool.py: add agent-browser-hermes_* glob to _reap_orphaned_browser_sessions()

Validation

19/19 browser CDP tests pass.

Closes #13081

Changed files

  • tools/browser_tool.py (modified, +2/-0)

Code Example

Report       https://paste.rs/nas1X
agent.log    https://paste.rs/lLeoj
gateway.log  https://paste.rs/QuQup

---
RAW_BUFFERClick to expand / collapse

Bug Description

When browser cloud_provider is set to browser-use (or other cloud providers), browser sessions are created with hermes_-prefixed session names. After unclean exits, orphaned agent-browser daemons for these sessions are not reaped, so they accumulate over time. This leads to process buildup and occasional socket/path failures on later browser_navigate calls.

First discovered with Hermes' help: <img width="425" height="665" alt="Image" src="https://github.com/user-attachments/assets/b049e887-419f-4004-8c5d-e9ae58e5da97" />

Steps to Reproduce

To be honest, not too sure if this will reproduce the issue but it's worth a shot:

  1. Configure browser cloud_provider to browser-use.
  2. Ensure Browser Use cloud is actually active (valid Browser Use credentials/gateway).
  3. Start Hermes and run one browser navigation task (for example, any task that triggers browser_navigate).
  4. Force-kill Hermes uncleanly (SIGKILL / hard stop) so normal cleanup does not run.
  5. Repeat steps 3-4 several times.
  6. Inspect running processes and temp dirs: a. You should see increasing agent-browser/node daemons. b. You should see agent-browser-hermes_* directories under /tmp.
  7. Start Hermes again and run browser_navigate repeatedly.
  8. Observe intermittent browser failures such as missing socket/parent directory errors while old daemons remain.

Expected Behavior

  1. On startup/cleanup, orphan reaping should detect and terminate orphaned agent-browser sessions regardless of naming prefix (h_, cdp_, hermes_, etc).
  2. Old cloud-session daemons should not accumulate across crashes/restarts.
  3. Browser navigation should remain stable without socket errors caused by stale daemons.

Actual Behavior

  1. Orphan reaper scans only h_ and cdp_ session directory patterns.
  2. hermes_-prefixed cloud sessions are skipped by orphan reaping.
  3. Over time, orphaned daemons accumulate and can contribute to socket/path instability. Eventually: browser_navigate fails with:Daemon failed to start (socket: /tmp/agent-browser-hermes_<timestamp>_<hash>_<hash>/default.sock)
<img width="1280" height="228" alt="Image" src="https://github.com/user-attachments/assets/2717c2b2-a562-4993-b395-8f1fa82b75c4" />

Affected Component

Tools (terminal, file ops, web, code execution, etc.)

Messaging Platform (if gateway-related)

No response

Debug Report

Report       https://paste.rs/nas1X
agent.log    https://paste.rs/lLeoj
gateway.log  https://paste.rs/QuQup

Operating System

MacOS 26.4

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

  1. Cloud providers create session names with a hermes_ prefix (Browser Use: browser_use.py, Browserbase: browserbase.py, and Firecrawl: firecrawl.py providers).
  2. The orphan reaper in the browser tool only scans socket directories matching h_ and cdp_ prefixes.
  3. Because hermes_ is not included in that scan pattern, orphaned cloud-session agent-browser daemons are skipped after crash or forced termination.
  4. Reaping is invoked on startup and cleanup paths, but the scan scope is incomplete, so hermes_ orphans persist.
  5. Active in-memory cleanup can still remove known sessions during a normal lifecycle, but that does not help when the process crashes and in-memory state is lost.

Proposed Fix (optional)

  1. Expand orphan discovery in the browser tool reaper to include all session naming prefixes used by browser backends, including hermes_.
  2. Prefer a robust pattern: scan all agent-browser-* directories, then rely on existing owner_pid and pid liveness checks to decide whether to reap.
  3. Keep current safety behavior so sessions owned by live Hermes processes are never reaped.
  4. Add regression tests covering orphan cleanup for h_, cdp_, and hermes_ session directories.
  5. Add a crash-recovery test scenario to ensure hermes_ cloud-session orphans are reaped on next startup.
  6. Optional hardening: standardize session naming across providers, or centralize session-name generation in one place to prevent future naming drift.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

The most likely fix is to modify the orphan reaper in the browser tool to include the hermes_ prefix in its scan pattern or to scan all agent-browser-* directories.

Guidance

  • Review the browser_use.py, browserbase.py, and firecrawl.py providers to understand how they generate session names with the hermes_ prefix.
  • Update the orphan reaper to scan all agent-browser-* directories, and rely on existing owner_pid and pid liveness checks to decide whether to reap.
  • Ensure that the updated reaper still skips sessions owned by live Hermes processes to prevent accidental termination.
  • Consider adding regression tests to cover orphan cleanup for h_, cdp_, and hermes_ session directories.

Example

No code example is provided as the issue does not contain sufficient information about the specific code changes required.

Notes

The proposed fix suggests modifying the orphan reaper to include the hermes_ prefix or to scan all agent-browser-* directories. However, the exact implementation details are not provided, and the issue lacks information about the Python version and Hermes version being used.

Recommendation

Apply the workaround by modifying the orphan reaper to scan all agent-browser-* directories, as this approach is more robust and less prone to errors. This change will ensure that orphaned cloud-session agent-browser daemons are properly reaped, regardless of their naming prefix.

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