{"record":{"id":"7dd159c700dda0e8","repo":"langchain-ai/deepagents","slug":"provide-exactly-one-of-mode-or-auto-approve","errorCode":null,"errorMessage":"Provide exactly one of mode or auto_approve","messagePattern":"Provide exactly one of mode or auto_approve","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/approval_mode.py","lineNumber":149,"sourceCode":"    mode: ApprovalMode | str | None = None,\n    auto_approve: bool | None = None,\n) -> ApprovalModePayload:\n    \"\"\"Return the stored approval-mode payload.\n\n    Args:\n        mode: Explicit approval mode.\n        auto_approve: Compatibility input for callers using the previous Boolean\n            API. `True` maps to unrestricted `yolo`, and `False` maps to `manual`.\n\n    Returns:\n        JSON-serializable store value.\n\n    Raises:\n        ValueError: If neither or both inputs are supplied, or `mode` is invalid.\n    \"\"\"\n    if (mode is None) == (auto_approve is None):\n        msg = \"Provide exactly one of mode or auto_approve\"\n        raise ValueError(msg)\n    if auto_approve is not None:\n        resolved = ApprovalMode.YOLO if auto_approve else ApprovalMode.MANUAL\n    else:\n        try:\n            resolved = ApprovalMode(mode)\n        except (TypeError, ValueError) as exc:\n            msg = f\"Invalid approval mode: {mode!r}\"\n            raise ValueError(msg) from exc\n    return {\"mode\": resolved.value}\n\n\ndef _item_value(item: object) -> object:\n    \"\"\"Extract a store item's value.\n\n    Args:\n        item: SDK or runtime store-item shape.\n\n    Returns:","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/approval_mode.py#L131-L167","documentation":"`approval_mode_payload` converts either an explicit `ApprovalMode` value or an `auto_approve` boolean into a payload dict. Exactly one of the two may be supplied; passing neither or both is ambiguous and raises this ValueError.","triggerScenarios":"Calling `approval_mode_payload()` with no arguments, or with both `mode=\"yolo\"` and `auto_approve=True`; usually from a caller that conditionally sets one flag but doesn't mutually exclude them.","commonSituations":"Settings screens that write both a boolean auto-approve toggle and a mode dropdown; refactors that added `mode` without removing `auto_approve`.","solutions":["Pass only `mode` (preferred): approval_mode_payload(mode=\"yolo\")","Or pass only the boolean: approval_mode_payload(auto_approve=True)","Guard the call site: if mode is not None: ... elif auto_approve is not None: ..."],"exampleFix":"// before\napproval_mode_payload(mode=\"manual\", auto_approve=True)\n// after\napproval_mode_payload(mode=\"manual\")","handlingStrategy":"validation","validationCode":"supplied = [arg for arg in (mode, auto_approve) if arg is not None]\nif len(supplied) != 1:\n    raise ValueError(\"Provide exactly one of mode or auto_approve\")","typeGuard":"def has_exactly_one(mode: str | None, auto_approve: bool | None) -> bool:\n    return (mode is None) != (auto_approve is None)","tryCatchPattern":"try:\n    payload = approval_mode_payload(mode=mode)\nexcept ValueError as exc:\n    logger.error(\"approval payload error: %s\", exc)","preventionTips":["Prefer passing mode explicitly; treat auto_approve as a legacy convenience","Make settings UIs mutually exclusive between the toggle and the dropdown","Centralize the mapping auto_approve -> mode in one place"],"tags":["approval-mode","api-misuse","mutually-exclusive-args"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}