Skip to content

Commit 0dfe24a

Browse files
committed
fix: reject unknown CLI args unless running in --reflect mode
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 #566
1 parent b1e173d commit 0dfe24a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

agentmain.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ def run(self):
206206
parser.add_argument('--nobg', action='store_true')
207207
parser.add_argument('--nolog', action='store_true')
208208
args, _unknown = parser.parse_known_args()
209-
_extra_args = dict(zip([k.lstrip('-') for k in _unknown[::2]], _unknown[1::2])) if _unknown else {}
209+
if _unknown and not args.reflect:
210+
# Reject unknown CLI flags unless we are in --reflect mode, where
211+
# extra key/value pairs are forwarded to the reflect script.
212+
# Without this guard, typos like `--goal` silently fall through to
213+
# interactive mode and the process looks alive without doing any work.
214+
parser.error(f"unrecognized arguments: {' '.join(_unknown)}")
215+
_reflect_args = dict(zip([k.lstrip('-') for k in _unknown[::2]], _unknown[1::2])) if _unknown else {}
210216

211217
if (args.func or args.task) and not args.nobg:
212218
import subprocess, platform

0 commit comments

Comments
 (0)