From a5f583fdb7131adf4cb7c02318cb3aac2639d889 Mon Sep 17 00:00:00 2001 From: Kailigithub <12250313+Kailigithub@users.noreply.github.com> Date: Fri, 24 Jul 2026 03:08:21 +0800 Subject: [PATCH] fix(agentmain): reject unknown CLI arguments 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. Re-roll of #697 onto current main (original PR drifted into CONFLICTING state due to ~60K lines of stale drift in the branch baseline). Closes #566 --- agentmain.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/agentmain.py b/agentmain.py index 6c5746bd9..7280834a8 100644 --- a/agentmain.py +++ b/agentmain.py @@ -207,6 +207,12 @@ def run(self): parser.add_argument('--nolog', action='store_true') parser.add_argument('--no-user-tools', action='store_true') args, _unknown = parser.parse_known_args() + if _unknown and not args.reflect: + # Reject unknown CLI flags unless we are in --reflect mode, where + # extra key/value pairs are forwarded to the reflect script as parameters. + # Without this guard, typos like `--goal` silently fall through to + # interactive mode and the process looks alive without doing any work. + parser.error(f"unrecognized arguments: {' '.join(_unknown)}") _extra_args = dict(zip([k.lstrip('-') for k in _unknown[::2]], _unknown[1::2])) if _unknown else {} if (args.func or args.task) and not args.nobg: