Skip to content

fix: reject unknown CLI args unless running in --reflect mode#568

Open
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-566-argguard-unknown-args
Open

fix: reject unknown CLI args unless running in --reflect mode#568
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-566-argguard-unknown-args

Conversation

@Kailigithub
Copy link
Copy Markdown
Contributor

Problem

agentmain.py used parse_known_args(), which silently accepted unknown
CLI flags. A typo like --goal (intended for a separate Hive launcher)
was swallowed without warning, causing the process to fall through into
the interactive agent loop in the background — the TUI looked frozen
because no master dispatch was ever published.

Reported in #566.

Fix

Add a guard after parse_known_args():

  • If unknown args are present and --reflect is not set, call
    parser.error(...) so argparse prints usage and exits non-zero.
  • The --reflect path is unchanged: extra --key value pairs are still
    forwarded to the reflect script as _reflect_args.

Verification

Local tests with a synthetic argv (no API keys required):

Test 1 — unknown --goal without --reflect:
  exit code: 2
  stderr:    usage: agentmain.py ...
             agentmain.py: error: unrecognized arguments: --goal /tmp/foo.json

Test 2 — --reflect with extra args (--base_url / --board_key):
  exit code: 0
  OK args= Namespace(... reflect='reflect/agent_team_master.py' ...) unknown= ['--base_url', '...']

Test 3 — no unknown args (--nobg only):
  argparse stage passes; later GeneraticAgent() raises unrelated to this change

ruff check agentmain.py --select F,E9 reports only pre-existing
findings (F541 f-string in another function, F401 side-effect readline
import) — none introduced by this patch.

Closes #566

Previously, agentmain.py used parse_known_args() and silently ignored
unknown flags. A typo like `--goal` (intended for a different launcher)
was accepted without warning, causing the process to fall through into
interactive mode and hang without dispatching any work.

Now, unknown arguments are only permitted when --reflect is set, since
extra key/value pairs are forwarded to the reflect script as parameters.
Otherwise parser.error() prints usage and exits non-zero.

Closes lsdefine#566
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.

Goal Hive can silently hang when launched with unsupported --goal argument

1 participant