Skip to content

Fix argparse nargs="*"REMAINDER for forwarded task args in run_tasks_in_agents_if_exists.py#89

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-argparse-nargs
Open

Fix argparse nargs="*"REMAINDER for forwarded task args in run_tasks_in_agents_if_exists.py#89
Copilot wants to merge 2 commits intomainfrom
copilot/fix-argparse-nargs

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Summary

nargs="*" causes argparse to treat any --prefixed token as an option flag, so args like --fix, -k, or -- passed after the task name would raise unrecognized arguments instead of being forwarded to Poe.

  • scripts/run_tasks_in_agents_if_exists.py: Change extra argument from nargs="*" to nargs=argparse.REMAINDER, so all trailing tokens—including flags—are collected verbatim and forwarded to the underlying Poe task.
# Before
parser.add_argument("extra", nargs="*", ...)

# After
parser.add_argument("extra", nargs=argparse.REMAINDER, ...)

Testing

  • Not run (why?)
  • uv run poe check
  • Other: CodeQL scan — 0 alerts

Checklist

  • Linked issue or task reference
  • Added/updated tests where relevant
  • Updated docs/README if needed
  • No secrets or sensitive data added
  • Considered backward compatibility and deployment impact

Additional context

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix argparse nargs="*" in run_tasks_in_agents_if_exists.py to use REMAINDER for forwarded task args</issue_title>
<issue_description>## Problem

In scripts/run_tasks_in_agents_if_exists.py at line 58, the extra argument is declared with nargs="*". This means values starting with - (e.g. --fix, -k, --) will be parsed as options by argparse and cause an "unrecognized arguments" error instead of being forwarded to Poe as intended.

File and Location

  • File: scripts/run_tasks_in_agents_if_exists.py
  • Line: 58

Suggested Fix

If this script is intended to pass through arbitrary task args, use argparse.REMAINDER (or parse_known_args) for the forwarded arguments so flags are accepted:

parser.add_argument("extra", nargs=argparse.REMAINDER, ...)

or

args, extra = parser.parse_known_args()

Original Review Comment

extra is declared with nargs="*", so values starting with - (e.g. --fix, -k, --) will be parsed as options and cause an "unrecognized arguments" error instead of being forwarded to Poe. If this script is intended to pass through arbitrary task args, use argparse.REMAINDER (or parse_known_args) for the forwarded arguments so flags are accepted.

References

Generated by PR Review Comment — Create Issue for issue #51

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: pmalarme <686568+pmalarme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix argparse nargs="*" to use REMAINDER in script Fix argparse nargs="*"REMAINDER for forwarded task args in run_tasks_in_agents_if_exists.py Feb 19, 2026
Copilot AI requested a review from pmalarme February 19, 2026 22:13
@pmalarme pmalarme marked this pull request as ready for review February 19, 2026 22:17
Copilot AI review requested due to automatic review settings February 19, 2026 22:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the run_tasks_in_agents_if_exists.py script where argparse was incorrectly treating flag-like arguments (e.g., --fix, -k) as unrecognized options instead of forwarding them to the underlying Poe task. The fix changes the extra argument from nargs="*" to nargs=argparse.REMAINDER, which captures all trailing tokens verbatim—including flags—and forwards them correctly.

Changes:

  • Updated scripts/run_tasks_in_agents_if_exists.py to use argparse.REMAINDER instead of nargs="*" for the extra argument, enabling proper forwarding of flag arguments to Poe tasks

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.

Fix argparse nargs="*" in run_tasks_in_agents_if_exists.py to use REMAINDER for forwarded task args

3 participants