Skip to content

fix(agent): intercept --version/--help in run_agent.main() - #54682

Open
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/agent-version-flag
Open

AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/agent-version-flag

Conversation

@AlexFucuson9

Copy link
Copy Markdown

Problem

pyproject.toml maps the hermes-agent console script to run_agent:main(), which has no CLI argument parsing. Running hermes-agent --version or hermes-agent --help starts a real agent run (initializing AIAgent, attempting provider requests) instead of printing version/help text and exiting.

The primary hermes --version command works correctly, but the hermes-agent entry point does not.

Fix

Add sys.argv check at the top of run_agent.main() to intercept --version/-V and --help/-h before the agent initializes. Mirrors the hermes_cli/main.py version output format.

Changes: 1 file (run_agent.py), 22 lines added.

Fixes #54648

…rch#54648)

pyproject.toml maps hermes-agent console script to run_agent:main(),
which has no CLI argument parsing. Running hermes-agent --version or
--help starts a real agent run instead of printing version/help text.

Add sys.argv check at the top of main() to handle --version/-V and
--help/-h before the agent initializes. Mirrors hermes_cli/main.py
version output format.

Fixes NousResearch#54648
@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
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Competing fix for #54648 (same root cause as #54649). This PR intercepts --version/--help with an inline sys.argv check at the top of run_agent.main(); #54649 (filed earlier) instead adds a dedicated legacy_cli_main() argparse wrapper and repoints the hermes-agent console script in pyproject.toml, which keeps --query/--model/--toolset flags working and is arguably cleaner. Flagging the cluster (#54648, #54649, this) so a maintainer can pick one approach.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused metadata-command fix. The underlying legacy-entrypoint bug is present on current main: pyproject.toml:309 still targets run_agent:main, and run_agent.py:5980-6008 constructs an agent and runs a query.

Problems

  • The new sys.argv guard is inside parameterized main() (run_agent.py:5839-5851). That changes programmatic calls to main(query=...) based on the embedding process's argv, rather than isolating console-script behavior.
  • Direct execution remains Fire-based at run_agent.py:6053-6055; intercepting --help here replaces its legacy argument help with a two-option message and does not establish parsing for the runner's existing options.
  • The diff adds no regression tests for the metadata paths.

Suggested changes

  • Put argv parsing in a dedicated legacy console wrapper and repoint pyproject.toml to it, leaving main() parameter-driven.
  • Cover version, help, no-argument, and query forwarding without constructing AIAgent. The competing #54649 provides a concrete wrapper-oriented direction noted in the discussion.

Automated hermes-sweeper review.

Comment thread run_agent.py
# Intercept --version / --help before initializing the agent.
# pyproject.toml maps the `hermes-agent` console script to this
# function, so `hermes-agent --version` must not start an agent run.
import sys as _sys

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main() is also a parameterized API. Reading process-global argv here means main(query=...) can silently return when an embedding host happened to start with -h or --version; put this check in a console-script wrapper instead.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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 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