Skip to content

refactor: consolidate get_hermes_home() and parse_reasoning_effort()#3062

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-d877fbc1
Mar 25, 2026
Merged

refactor: consolidate get_hermes_home() and parse_reasoning_effort()#3062
teknium1 merged 1 commit intomainfrom
hermes/hermes-d877fbc1

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Centralizes two widely-duplicated patterns into hermes_constants.py (zero-dependency module, import-safe everywhere).

31 files changed, 125 insertions(+), 94 deletions(-)

1. get_hermes_home() — single source of truth for HERMES_HOME resolution

The pattern Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) was copy-pasted across 30+ files. Now defined once in hermes_constants.py and imported everywhere.

  • hermes_cli/config.py re-exports it for backward compatibility (existing from hermes_cli.config import get_hermes_home still works)
  • Removed 4 local wrapper functions that were doing the same thing:
    • honcho_integration/client.py::_get_hermes_home()
    • tools/website_policy.py::_get_hermes_home()
    • tools/tirith_security.py::_get_hermes_home()
    • hermes_cli/uninstall.py::get_hermes_home()

2. parse_reasoning_effort() — shared reasoning effort validation

The same validation logic (xhigh/high/medium/low/minimal/none) was copy-pasted in 3 places:

  • cli.py::_parse_reasoning_config()
  • gateway/run.py::_load_reasoning_config()
  • cron/scheduler.py (inline)

Now parse_reasoning_effort() lives in hermes_constants.py. Call sites still handle their own warning logs (context-specific messages).

Skipped for this PR

Provider URL detection consolidation (is_openrouter, is_anthropic, is_direct_openai) — touches hot code paths in run_agent.py, higher risk. Saved for a separate PR.

Test results

6179 passed, 200 skipped, 23 deselected, 25 warnings
0 failures

E2E PTY test: banner renders, tool calls work, no garbled ANSI.

Centralizes two widely-duplicated patterns into hermes_constants.py:

1. get_hermes_home() — Path resolution for ~/.hermes (HERMES_HOME env var)
   - Was copy-pasted inline across 30+ files as:
     Path(os.getenv("HERMES_HOME", Path.home() / ".hermes"))
   - Now defined once in hermes_constants.py (zero-dependency module)
   - hermes_cli/config.py re-exports it for backward compatibility
   - Removed local wrapper functions in honcho_integration/client.py,
     tools/website_policy.py, tools/tirith_security.py, hermes_cli/uninstall.py

2. parse_reasoning_effort() — Reasoning effort string validation
   - Was copy-pasted in cli.py, gateway/run.py, cron/scheduler.py
   - Same validation logic: check against (xhigh, high, medium, low, minimal, none)
   - Now defined once in hermes_constants.py, called from all 3 locations
   - Warning log for unknown values kept at call sites (context-specific)

31 files changed, net +31 lines (125 insertions, 94 deletions)
Full test suite: 6179 passed, 0 failed
@teknium1 teknium1 merged commit 77bcaba into main Mar 25, 2026
4 checks passed
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…ousResearch#3062)

Centralizes two widely-duplicated patterns into hermes_constants.py:

1. get_hermes_home() — Path resolution for ~/.hermes (HERMES_HOME env var)
   - Was copy-pasted inline across 30+ files as:
     Path(os.getenv("HERMES_HOME", Path.home() / ".hermes"))
   - Now defined once in hermes_constants.py (zero-dependency module)
   - hermes_cli/config.py re-exports it for backward compatibility
   - Removed local wrapper functions in honcho_integration/client.py,
     tools/website_policy.py, tools/tirith_security.py, hermes_cli/uninstall.py

2. parse_reasoning_effort() — Reasoning effort string validation
   - Was copy-pasted in cli.py, gateway/run.py, cron/scheduler.py
   - Same validation logic: check against (xhigh, high, medium, low, minimal, none)
   - Now defined once in hermes_constants.py, called from all 3 locations
   - Warning log for unknown values kept at call sites (context-specific)

31 files changed, net +31 lines (125 insertions, 94 deletions)
Full test suite: 6179 passed, 0 failed
StreamOfRon pushed a commit to StreamOfRon/hermes-agent that referenced this pull request Mar 29, 2026
…ousResearch#3062)

Centralizes two widely-duplicated patterns into hermes_constants.py:

1. get_hermes_home() — Path resolution for ~/.hermes (HERMES_HOME env var)
   - Was copy-pasted inline across 30+ files as:
     Path(os.getenv("HERMES_HOME", Path.home() / ".hermes"))
   - Now defined once in hermes_constants.py (zero-dependency module)
   - hermes_cli/config.py re-exports it for backward compatibility
   - Removed local wrapper functions in honcho_integration/client.py,
     tools/website_policy.py, tools/tirith_security.py, hermes_cli/uninstall.py

2. parse_reasoning_effort() — Reasoning effort string validation
   - Was copy-pasted in cli.py, gateway/run.py, cron/scheduler.py
   - Same validation logic: check against (xhigh, high, medium, low, minimal, none)
   - Now defined once in hermes_constants.py, called from all 3 locations
   - Warning log for unknown values kept at call sites (context-specific)

31 files changed, net +31 lines (125 insertions, 94 deletions)
Full test suite: 6179 passed, 0 failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant