Skip to content

runner.py: reject zero or negative agent, fan-out and budget values - #6

Merged
theluckystrike merged 1 commit into
theluckystrike:mainfrom
jay23606:pr-go/3-runner-py-accepts-zero-or-negative-agent
Oct 28, 2026
Merged

theluckystrike merged 1 commit into
theluckystrike:mainfrom
jay23606:pr-go/3-runner-py-accepts-zero-or-negative-agent

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

Problem

pipeline/runner.py takes --agents, --fan-out and --budget as plain int/float with no range check. The preset builders slice with prompts[:n], so bad values change the run silently:

  • --agents 0 builds zero tasks.
  • --agents -3 builds 17 tasks for market_scan, because a negative slice drops items from the end.
  • --budget 0 or below is accepted.

Change

  • parse_args() now calls a small _check_positive_args() helper after p.parse_args(). It rejects --agents < 1, --fan-out < 1 and --budget <= 0 with p.error(...), which prints a usage message and exits with status 2.
  • Defaults are unchanged. The helper is a separate function so parse_args() stays under the 60-line rule.

Testing

Added pipeline/test_runner_args.py, which runs the dry-run path with each invalid value and expects exit status 2, and runs --preset market_scan --agents 5 --dry-run and expects 5 tasks. It needs no API key or extra packages.

  • Before the fix, python pipeline/test_runner_args.py fails on all five invalid values (exit 0 instead of 2).
  • After the fix, it passes.
  • python pipeline/runner.py --preset market_scan --agents -3 --dry-run now exits 2 with --agents must be at least 1 (got -3).
  • python pipeline/runner.py --preset market_scan --agents 5 --dry-run still prints the summary and exits 0.

The other commands in the issue (--agents 0, --fan-out 0, --budget 0) were also run and exit 2 with the matching message.

Regression test: fails on base twice (/exit=\d+ expected=2/), passes on fix twice (python pipeline/test_runner_args.py)

Fixes #3

@jay23606

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@theluckystrike

Copy link
Copy Markdown
Owner

Thanks for this, Jay. The fix is small and clear, and the error messages tell the user exactly what went wrong.

I checked out the branch and ran the CI steps locally plus python pipeline/test_runner_args.py on Python 3.11 and 3.9, and it passes. I also ran your test against the old runner.py and it failed on all five bad values, so it really guards the fix. Valid input still works as before. The default market_scan dry run builds 20 tasks, --agents 1 builds 1, --prompt hi with the default fan-out builds 20, --budget 0.01 is accepted and --tasks bln_100_agents.json still builds 100. The agent and budget checks also match the asserts already in Orchestrator, so a bad value now fails early with a clear message instead of a traceback on a real run.

Merging now with a squash. Happy Hacktoberfest.

@theluckystrike theluckystrike added the hacktoberfest-accepted Accepted Hacktoberfest contribution label Oct 28, 2026
@theluckystrike
theluckystrike merged commit cc93372 into theluckystrike:main Oct 28, 2026
3 checks passed
@jay23606
jay23606 deleted the pr-go/3-runner-py-accepts-zero-or-negative-agent branch October 28, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Accepted Hacktoberfest contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runner.py accepts zero or negative agent counts and silently builds the wrong task list

2 participants