fix(agentmain): reject unknown CLI arguments (v3, re-roll onto current main)#703
Open
Kailigithub wants to merge 1 commit into
Open
fix(agentmain): reject unknown CLI arguments (v3, re-roll onto current main)#703Kailigithub wants to merge 1 commit into
Kailigithub wants to merge 1 commit into
Conversation
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 lsdefine#697 onto current main (original PR drifted into CONFLICTING state due to ~60K lines of stale drift in the branch baseline). Closes lsdefine#566
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject unsupported command-line arguments before GenericAgent initializes. This makes mistyped launch modes such as
--goalfail with argparse's non-zero error instead of falling through to the interactive path.Problem
agentmain.pyusedparse_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 to interactive mode and hang without dispatching any work — users reported "agent launched but did nothing."Fix
Single-source change in
agentmain.py: when_unknown(leftover fromparse_known_args()) is non-empty AND--reflectis not active, callparser.error()to print usage and exit non-zero.--reflectmode is exempted because reflect scripts receive the extra key/value pairs as parameters and need them forwarded (existing behavior preserved).Verification
python3 -m py_compile agentmain.py— syntax OK/tmp/test_issue_566.py— 4 checks:if _unknown and not args.reflect+parser.errorare present.python3 agentmain.py --goal /tmp/foo.jsonexits with code 2 and the messageunrecognized arguments: --goal /tmp/foo.json.--helpexits 0 without the new guard firing._extra_argsdict assignment is untouched.Scope