langchain-ai/deepagents · error · ValueError
Provide exactly one of mode or auto_approve
Error message
Provide exactly one of mode or auto_approve
What it means
`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.
Source
Thrown at libs/code/deepagents_code/approval_mode.py:149
mode: ApprovalMode | str | None = None,
auto_approve: bool | None = None,
) -> ApprovalModePayload:
"""Return the stored approval-mode payload.
Args:
mode: Explicit approval mode.
auto_approve: Compatibility input for callers using the previous Boolean
API. `True` maps to unrestricted `yolo`, and `False` maps to `manual`.
Returns:
JSON-serializable store value.
Raises:
ValueError: If neither or both inputs are supplied, or `mode` is invalid.
"""
if (mode is None) == (auto_approve is None):
msg = "Provide exactly one of mode or auto_approve"
raise ValueError(msg)
if auto_approve is not None:
resolved = ApprovalMode.YOLO if auto_approve else ApprovalMode.MANUAL
else:
try:
resolved = ApprovalMode(mode)
except (TypeError, ValueError) as exc:
msg = f"Invalid approval mode: {mode!r}"
raise ValueError(msg) from exc
return {"mode": resolved.value}
def _item_value(item: object) -> object:
"""Extract a store item's value.
Args:
item: SDK or runtime store-item shape.
Returns:View on GitHub (pinned to a1af029e6e)
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: ...
Example fix
// before approval_mode_payload(mode="manual", auto_approve=True) // after approval_mode_payload(mode="manual")
Defensive patterns
Strategy: validation
Validate before calling
supplied = [arg for arg in (mode, auto_approve) if arg is not None]
if len(supplied) != 1:
raise ValueError("Provide exactly one of mode or auto_approve") Type guard
def has_exactly_one(mode: str | None, auto_approve: bool | None) -> bool:
return (mode is None) != (auto_approve is None) Try / catch
try:
payload = approval_mode_payload(mode=mode)
except ValueError as exc:
logger.error("approval payload error: %s", exc) Prevention
- 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
When it happens
Trigger: 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.
Common situations: Settings screens that write both a boolean auto-approve toggle and a mode dropdown; refactors that added `mode` without removing `auto_approve`.
Related errors
- Invalid approval mode: {mode!r}
- a provider already serves rank {provider.rank}
- Approval-mode Store writer is unavailable
- Manual approval mode could not be persisted; graph execution
- Manual mode callback is unavailable
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/7dd159c700dda0e8.
Report an issue: GitHub.