Skip to content

fix(cli): guard legacy hermes-agent entrypoint - #54649

Open
ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/legacy-entrypoint-help
Open

ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/legacy-entrypoint-help

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jun 29, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes the legacy hermes-agent console script so metadata/probe invocations are side-effect free.

Today pyproject.toml maps hermes-agent directly to run_agent:main. A generated console script calls that function with no parsed CLI args, so hermes-agent --version, hermes-agent --help, and even bare hermes-agent can fall into the default Python 3.13 demo prompt and start a live agent/provider request.

This PR adds a small argparse wrapper for the legacy entry point and points the packaged script at it. The wrapper handles --version, --help, and no-argument invocations without calling main(), while preserving explicit runs through --query, positional prompt text, and the existing model/toolset flags.

Related note: #13712 also touches adjacent legacy version handling, but it is a broad 5k+ line integration PR. This PR keeps the fix narrow and reviewable.

Related Issue

Fixes #54648

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

  • run_agent.py: add legacy_cli_main() and a legacy argparse parser for hermes-agent.
  • pyproject.toml: point hermes-agent at run_agent:legacy_cli_main.
  • tests/run_agent/test_legacy_cli_entrypoint.py: cover --version, --help, no args, explicit query dispatch, and packaged script target.
  • tests/hermes_cli/test_verify_console_scripts.py: update the fake pyproject fixture to match the real script target.

How to Test

Reproduced on Windows with the installed hermes-agent.exe --version, which started the default Python 3.13 demo agent path and attempted a provider request before failing.

Validated the fix with:

  1. uv run --extra dev python -m pytest tests\run_agent\test_legacy_cli_entrypoint.py -q
    • 5 passed
  2. uv run --extra dev python -m pytest tests\hermes_cli\test_verify_console_scripts.py -q
    • 6 passed
  3. uv run --extra dev python -m pytest tests\test_hermes_bootstrap.py::TestEntryPointsImportBootstrap::test_entry_point_imports_bootstrap -q
    • 6 passed
  4. uv run --extra dev python -m ruff check run_agent.py tests\run_agent\test_legacy_cli_entrypoint.py tests\hermes_cli\test_verify_console_scripts.py
    • passed; ruff still reports an existing warning for an unrelated invalid # noqa directive in run_agent.py
  5. python -m py_compile run_agent.py
  6. Smoke-tested the generated worktree console script:
    • .venv\Scripts\hermes-agent.exe --version
    • .venv\Scripts\hermes-agent.exe --help
    • .venv\Scripts\hermes-agent.exe

I first tried the canonical bash scripts/run_tests.sh tests/run_agent/test_legacy_cli_entrypoint.py -q, but this Windows worktree had no .venv/venv and the script's POSIX $HOME/.hermes/hermes-agent/venv fallback did not match the local Windows install location.

Checklist

Code

  • I've read the Contributing Guide / repo guidance
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: Windows 11 Pro 10.0.22631, Python 3.11.15

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) - N/A
  • I've updated cli-config.yaml.example if I added/changed config keys - N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows - N/A
  • I've considered cross-platform impact (Windows, macOS) - console script behavior is platform-independent; reproduced on Windows
  • I've updated tool descriptions/schemas if I changed tool behavior - N/A

Screenshots / Logs

No raw failing provider output is included because the failing path can print credential-bearing request metadata. The regression tests and console-script smoke cover the side-effect-free behavior directly.

@ooiuuii
ooiuuii requested a review from a team June 29, 2026 05:23
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels Jun 29, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused fix. The premise is verified on current main: pyproject.toml:309 still maps hermes-agent directly to run_agent:main, while run_agent.py:5980-6008 initializes an agent, supplies the default Python 3.13 query when query is None, and runs the conversation. The generated local console-script shim likewise calls main() without parsing or forwarding arguments.

The PR's separate legacy_cli_main() wrapper and script-target change address that path without changing main()'s programmatic API. The wrapper covers all current main() parameters (run_agent.py:5839-5851) and its tests cover the requested metadata/no-argument and query-dispatch paths.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes-agent --version starts an agent run instead of printing version

3 participants