fix(agent): intercept --version/--help in run_agent.main() - #54682
AlexFucuson9 wants to merge 1 commit into
Conversation
…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
Competing fix for #54648 (same root cause as #54649). This PR intercepts |
teknium1
left a comment
There was a problem hiding this comment.
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.argvguard is inside parameterizedmain()(run_agent.py:5839-5851). That changes programmatic calls tomain(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--helphere 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.tomlto it, leavingmain()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.
| # 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 |
There was a problem hiding this comment.
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.
Problem
pyproject.tomlmaps thehermes-agentconsole script torun_agent:main(), which has no CLI argument parsing. Runninghermes-agent --versionorhermes-agent --helpstarts a real agent run (initializing AIAgent, attempting provider requests) instead of printing version/help text and exiting.The primary
hermes --versioncommand works correctly, but thehermes-agententry point does not.Fix
Add
sys.argvcheck at the top ofrun_agent.main()to intercept--version/-Vand--help/-hbefore the agent initializes. Mirrors thehermes_cli/main.pyversion output format.Changes: 1 file (
run_agent.py), 22 lines added.Fixes #54648