{"record":{"id":"9078415401a84d5d","repo":"langchain-ai/deepagents","slug":"invalid-recent-startup-mode-mode-r","errorCode":null,"errorMessage":"Invalid recent startup mode: {mode!r}","messagePattern":"Invalid recent startup mode: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/model_config.py","lineNumber":6316,"sourceCode":"\n\ndef save_recent_startup_mode(mode: str, config_path: Path | None = None) -> bool:\n    \"\"\"Save the most recently selected safe startup approval mode.\n\n    Args:\n        mode: `\"manual\"` or `\"auto\"`.\n        config_path: Path to config file.\n\n    Returns:\n        `True` when the preference was saved, otherwise `False`.\n\n    Raises:\n        ValueError: If `mode` is not `\"manual\"` or `\"auto\"`. `yolo` must stay\n            explicitly configured, so it is never stored as a recent mode.\n    \"\"\"\n    if mode not in RECENT_STARTUP_MODES:\n        msg = f\"Invalid recent startup mode: {mode!r}\"\n        raise ValueError(msg)\n    return _save_toml_field(\"startup\", \"recent\", mode, config_path)\n\n\ndef save_thread_sort_order(sort_order: str, config_path: Path | None = None) -> bool:\n    \"\"\"Save the sort order preference for the thread selector.\n\n    Args:\n        sort_order: `\"updated_at\"` or `\"created_at\"`.\n        config_path: Path to config file.\n\n    Returns:\n        True if save succeeded, False on I/O error.\n\n    Raises:\n        ValueError: If `sort_order` is not a recognised value.\n    \"\"\"\n    if sort_order not in {\"updated_at\", \"created_at\"}:\n        msg = (","sourceCodeStart":6298,"sourceCodeEnd":6334,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/model_config.py#L6298-L6334","documentation":"save_recent_startup_mode persists the last explicitly chosen startup mode ('manual' or 'auto') to the `startup.recent` TOML field. Before saving it validates the mode against RECENT_STARTUP_MODES and raises ValueError('Invalid recent startup mode: {mode!r}') for anything else. `yolo` and other modes are deliberately excluded because they must remain explicitly configured, never stored as a recent mode.","triggerScenarios":"Calling save_recent_startup_mode(\"yolo\"), save_recent_startup_mode(\"\"), or any value other than \"manual\"/\"auto\" (case-sensitive), with an optional config_path.","commonSituations":"Passing a UI enum value straight through (e.g. 'yolo') without mapping to a restorable recent mode; capitalization mistakes ('Auto'); reading a stale/legacy value from config and echoing it back to save.","solutions":["Only call with \"manual\" or \"auto\"; map other startup modes (like yolo) to one of the two or skip saving.","Normalize case before calling: mode.lower() and validate membership in RECENT_STARTUP_MODES.","Check the caller is not persisting a legacy config value; filter it through is_recent_startup_mode_restorable first."],"exampleFix":"// before\nsave_recent_startup_mode(mode)  # mode may be \"yolo\"\n// after\nif mode in RECENT_STARTUP_MODES:\n    save_recent_startup_mode(mode)","handlingStrategy":"type-guard","validationCode":"RECENT_STARTUP_MODES = {\"manual\", \"auto\"}\nif not isinstance(mode, str) or mode not in RECENT_STARTUP_MODES:\n    return  # skip saving instead of raising","typeGuard":"def is_recent_startup_mode(mode: object) -> TypeGuard[str]:\n    return isinstance(mode, str) and mode in {\"manual\", \"auto\"}","tryCatchPattern":"try:\n    save_recent_startup_mode(mode)\nexcept ValueError:\n    logging.warning(\"Ignored non-restorable startup mode %r\", mode)","preventionTips":["Gate saves with is_recent_startup_mode_restorable or membership in RECENT_STARTUP_MODES.","Never persist 'yolo'; treat it as explicitly configured only.","Normalize user input case before saving."],"tags":["python","validation","config","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}