{"record":{"id":"19fc495bc3518569","repo":"FoundationAgents/MetaGPT","slug":"invalid-stage-stage-mode-mode","errorCode":null,"errorMessage":"invalid stage: {stage}, mode: {mode}","messagePattern":"invalid stage: (.+?), mode: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/ext/android_assistant/roles/android_assistant.py","lineNumber":75,"sourceCode":"            # Remember, only run each action only one time, no need to run n_round.\n            self.set_actions([ManualRecord, ParseRecord])\n            self.task_dir = data_dir.joinpath(app_name, f\"manual_learn_{cur_datetime}\")\n            self.docs_dir = data_dir.joinpath(app_name, \"manual_docs\")\n        elif stage == \"learn\" and mode == \"auto\":\n            # choose SelfLearnAndReflect to run\n            self.set_actions([SelfLearnAndReflect])\n            self.task_dir = data_dir.joinpath(app_name, f\"auto_learn_{cur_datetime}\")\n            self.docs_dir = data_dir.joinpath(app_name, \"auto_docs\")\n        elif stage == \"act\":\n            # choose ScreenshotParse to run\n            self.set_actions([ScreenshotParse])\n            self.task_dir = data_dir.joinpath(app_name, f\"act_{cur_datetime}\")\n            if mode == \"manual\":\n                self.docs_dir = data_dir.joinpath(app_name, \"manual_docs\")\n            else:\n                self.docs_dir = data_dir.joinpath(app_name, \"auto_docs\")\n        else:\n            raise ValueError(f\"invalid stage: {stage}, mode: {mode}\")\n\n        self._check_dir()\n\n        self._set_react_mode(RoleReactMode.BY_ORDER)\n\n    def _check_dir(self):\n        self.task_dir.mkdir(parents=True, exist_ok=True)\n        self.docs_dir.mkdir(parents=True, exist_ok=True)\n\n    async def react(self) -> Message:\n        self.round_count += 1\n        result = await super().react()\n        logger.debug(f\"react result {result}\")\n        return result\n\n    async def _observe(self, ignore_memory=True) -> int:\n        \"\"\"ignore old memory to make it run multi rounds inside a role\"\"\"\n        newest_msgs = self.rc.memory.get(k=1)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/ext/android_assistant/roles/android_assistant.py#L57-L93","documentation":"Raised by AndroidAssistant.__init__ when the `stage`/`mode` values from the run config do not match any supported combination. Supported branches are stage='learn' with mode='manual' or 'auto', and stage='act' (any mode). Any other stage value (or a missing stage) falls into the else and raises.","triggerScenarios":"Running the android assistant with extra_config stage not in {'learn','act'}, e.g. stage='test', stage=None (key omitted from the config), or a typo like 'acting'.","commonSituations":"Copied example config missing the 'stage' key; typo in the YAML/CLI value; expecting an undocumented stage such as 'eval'.","solutions":["Set stage to 'learn' (with mode 'manual' or 'auto') or 'act' in the extra config","Check that the config key is exactly 'stage' under extra_config, not nested elsewhere or misspelled","Run a documented example config first to confirm the expected keys"],"exampleFix":"# before\nextra_config = {\"app_name\": \"demo\", \"stage\": \"run\"}\n\n# after\nextra_config = {\"app_name\": \"demo\", \"stage\": \"act\", \"mode\": \"auto\"}","handlingStrategy":"validation","validationCode":"extra = {\"stage\": \"learn\", \"mode\": \"auto\", \"app_name\": \"demo\"}\nassert extra.get(\"stage\") in {\"learn\", \"act\"}\nassert extra.get(\"stage\") != \"learn\" or extra.get(\"mode\") in {\"manual\", \"auto\"}","typeGuard":"def is_valid_stage_mode(extra: dict) -> bool:\n    stage, mode = extra.get(\"stage\"), extra.get(\"mode\")\n    return stage == \"act\" or (stage == \"learn\" and mode in (\"manual\", \"auto\"))","tryCatchPattern":null,"preventionTips":["Copy a working example config and only change values, not keys","Validate stage/mode before constructing AndroidAssistant"],"tags":["android-assistant","config","validation"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}