Skip to content

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

Open

Description

@BlueX888

Describe the bug

sweagent run-api crashes with ModuleNotFoundError: No module named 'sweagent.api'. The subcommand is advertised in sweagent --help (the module docstring at sweagent/run/run.py:26 lists run-api: Run swe-agent as a backend for a GUI) and is accepted by argparse (registered as a choice at sweagent/run/run.py:46), but its dispatch branch at sweagent/run/run.py:105-108 does from sweagent.api.server import run_from_cli as run_api_main — and no sweagent/api package or module exists anywhere in the tree (sweagent/ contains only agent, environment, exceptions.py, inspector, run, tools, types.py, utils). pyproject.toml provides no optional extra for it either ([project.optional-dependencies] at pyproject.toml:69 only defines dev). The subcommand therefore can never start.

Expected behaviour: a subcommand that is advertised in sweagent --help and accepted by argparse should either run or fail with a clear message, not crash on importing a module that is not shipped.

Root cause: sweagent/run/run.py:105-108 dispatches run-api to sweagent.api.server, which does not exist in the package — the import at run.py:106 is the only reference to sweagent.api in the entire tree. Either the run-api choice, dispatch branch and help entry should be removed, or the import should be guarded (e.g. try/except ImportError printing "not available in this build" and exiting 1); if the API server is meant to ship, the sweagent/api module needs to be restored.

I searched this repo's issues and PRs for "run-api", "sweagent.api" and "ModuleNotFoundError api" and found no existing report of this.

Happy to open a PR implementing either approach (drop the choice + help entry, or guard the import).

Steps/commands/code to Reproduce

Installed from source at commit 3ea751c087f32b16e039a2233dd6eefecef325d5 (current main) into a venv, then ran the advertised subcommand:

pip install -e .
sweagent run-api

run-api is listed by sweagent --help:

run-api: Run swe-agent as a backend for a GUI

so argparse accepts it and execution reaches the dispatch in sweagent/run/run.py:105-108.

Error message/results

👋 INFO     This is SWE-agent version 1.1.0                                     
            (hash='3ea751c087f32b16e039a2233dd6eefecef325d5') with SWE-ReX      
            version 1.4.0 (rex_hash='unavailable').                             
Traceback (most recent call last):
  File "/Users/admin/.claude/oss-contributor/work/sweagent_venv/bin/sweagent", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/admin/.claude/oss-contributor/work/SWE-agent.tree/sweagent/run/run.py", line 106, in main
    from sweagent.api.server import run_from_cli as run_api_main
ModuleNotFoundError: No module named 'sweagent.api'

Exit code 1. Expected: the GUI backend starts, or a clear "not available in this build" error — not a raw traceback.

System Information

  • SWE-agent 1.1.0, commit 3ea751c087f32b16e039a2233dd6eefecef325d5 (current main)
  • Python 3.12.14
  • macOS 26.6, arm64
  • swebench package: n/a

Checklist

  • I'm running with the latest docker container/on the latest development version (i.e., I ran git pull))
  • I have copied the full command/code that I ran (as text, not as screenshot!)
  • If applicable: I have copied the full log file/error message that was the result (as text, not as screenshot!)
  • I have enclosed code/log messages in triple backticks (docs) and clicked "Preview" to make sure it's displayed correctly.

Activity

  1. BlueX888 commented on Oct 11, 2026

    @BlueX888
    Author

    Reproduced this. Root cause: sweagent/run/run.py:106 — the run-api dispatch branch imports sweagent.api.server, which does not exist anywhere in the package, so every invocation of the advertised subcommand raises ModuleNotFoundError.

    Minimal reproduction:

    pip install -e .
    sweagent run-api
    

    Observed output:

    Traceback (most recent call last):
      File "/Users/admin/.claude/oss-contributor/work/sweagent_venv/bin/sweagent", line 10, in <module>
      File "/Users/admin/.claude/oss-contributor/work/SWE-agent.tree/sweagent/run/run.py", line 106, in main
        from sweagent.api.server import run_from_cli as run_api_main
    ModuleNotFoundError: No module named 'sweagent.api'
    Exit code 1.
    

    Happy to open a PR with this fix, or to be assigned if you prefer to take it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions