FoundationAgents/MetaGPT · error · ValueError

Invalid exp_mode: {args.exp_mode}

Error message

Invalid exp_mode: {args.exp_mode}

What it means

Raised by SELA's experiment entrypoint when --exp_mode is not one of the recognized runners: 'mcts' (tree_mode random), 'rs' (RandomSearchRunner), 'base', 'autogluon', 'custom', 'autosklearn'. The dispatch is an if/elif chain with this final else.

Source

Thrown at metagpt/ext/sela/run_experiment.py:93

async def main(args):
    if args.exp_mode == "mcts":
        runner = MCTSRunner(args)
    elif args.exp_mode == "greedy":
        runner = MCTSRunner(args, tree_mode="greedy")
    elif args.exp_mode == "random":
        runner = MCTSRunner(args, tree_mode="random")
    elif args.exp_mode == "rs":
        runner = RandomSearchRunner(args)
    elif args.exp_mode == "base":
        runner = Runner(args)
    elif args.exp_mode == "autogluon":
        runner = GluonRunner(args)
    elif args.exp_mode == "custom":
        runner = CustomRunner(args)
    elif args.exp_mode == "autosklearn":
        runner = AutoSklearnRunner(args)
    else:
        raise ValueError(f"Invalid exp_mode: {args.exp_mode}")
    await runner.run_experiment()


if __name__ == "__main__":
    args = get_args()
    asyncio.run(main(args))

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Use one of: mcts, rs, base, autogluon, custom, autosklearn
  2. Check for typos/whitespace in the --exp_mode argument
  3. Run with --help to list the choices supported by your installed version

Example fix

# before
python -m metagpt.ext.sela.run_experiment --exp_mode random ...

# after
python -m metagpt.ext.sela.run_experiment --exp_mode rs ...
Defensive patterns

Strategy: validation

Validate before calling

import argparse
parser.add_argument("--exp_mode", choices=["mcts", "rs", "base", "autogluon", "custom", "autosklearn"])  # argparse then rejects bad values for you

Type guard

def is_valid_exp_mode(mode: str) -> bool:
    return mode in {"mcts", "rs", "base", "autogluon", "custom", "autosklearn"}

Prevention

When it happens

Trigger: Running run_experiment.py with an unknown --exp_mode value, e.g. 'mcts-improved', 'random', or a typo like 'autogluon ' with trailing whitespace.

Common situations: Typos on the CLI; using an exp_mode documented in a different SELa version; copy-pasting a command from a fork that added new modes.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/3ca4257c77608c71. Report an issue: GitHub.