fix: remove run-api subcommand dispatching to missing module by BlueX888 · Pull Request #1604 · SWE-agent/SWE-agent · GitHub
Skip to content

fix: remove run-api subcommand dispatching to missing module - #1604

Open
BlueX888 wants to merge 1 commit into
SWE-agent:mainfrom
BlueX888:fix/prep-run-api-dispatch-imports-nonexistent-sweagent-api-module
Open

BlueX888 wants to merge 1 commit into
SWE-agent:mainfrom
BlueX888:fix/prep-run-api-dispatch-imports-nonexistent-sweagent-api-module

Conversation

@BlueX888

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #1602

What does this implement/fix? Explain your changes.

Summary

sweagent run-api was advertised in the CLI help and accepted by argparse, but every invocation crashed with a raw traceback:

ModuleNotFoundError: No module named 'sweagent.api'

Why (root cause)

The dispatch branch in sweagent/run/run.py (elif command == "run-api": → from sweagent.api.server import run_from_cli as run_api_main, run.py:105-108 before this change) imports a module that does not exist anywhere in the package: sweagent/ contains only agent, environment, exceptions.py, inspector, run, tools, types.py and utils, and pyproject.toml defines no optional extra providing it. The advertised subcommand therefore could never start.

Changes

  • sweagent/run/run.py: remove the dead run-api entry from the CLI help docstring, from the command choices in get_cli(), and from the dispatch in main().
  • tests/test_run.py: add a regression test that dispatches --help for every subcommand accepted by get_cli() and asserts each exits cleanly instead of raising, so a dispatch to a missing module cannot be reintroduced unnoticed.

After this change sweagent run-api is rejected by argparse with the standard invalid choice: 'run-api' usage error (exit code 2), and sweagent --help no longer advertises it.

Testing

  • New regression test on unpatched main (3ea751c): pytest tests/test_run.py -q → 1 failed, 23 passed, failing in test_cli_subcommand_help_dispatches[run-api] with ModuleNotFoundError: No module named 'sweagent.api' at sweagent/run/run.py:106.
  • This branch: pytest tests/test_run.py -q → 23 passed.
  • Full suite (this sandbox has no docker/network access, so docker/network-dependent tests fail on both trees):
    • this branch: 26 failed, 122 passed, 3 xfailed
    • unpatched main: 26 failed, 102 passed, 3 xfailed
    • the 26 failing tests are identical on both trees (verified by diffing the sorted FAILED lists); no new failures.
  • ruff check sweagent/run/run.py tests/test_run.py → All checks passed!
  • ruff format --check sweagent/run/run.py tests/test_run.py → 2 files already formatted

`sweagent run-api` was advertised in the CLI help and accepted by
argparse, but its dispatch imports `sweagent.api.server`, which does
not exist anywhere in the package, so every invocation crashed with
ModuleNotFoundError. Remove the dead help entry, argparse choice, and
dispatch branch, and add a regression test that dispatches --help for
every accepted subcommand.
sun04222 added a commit to sun04222/SWE-agent that referenced this pull request Oct 23, 2026

This branch has not been deployed

No deployments
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.

run orchestration CLI: sweagent run-api dispatch imports nonexistent sweagent.api.server → hard ModuleNotFoundError

1 participant