diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index 850f8ff41..1f91bc5ef 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -19,6 +19,8 @@ cast, ) +from pydantic import BaseModel + from langchain_core.runnables import Runnable, RunnableConfig from typing_extensions import Self @@ -271,7 +273,7 @@ class Command(Generic[N], ToolOutputMixin): """ graph: Optional[str] = None - update: Union[dict[str, Any], Sequence[tuple[str, Any]]] = () + update: Union[dict[str, Any], Sequence[tuple[str, Any]], BaseModel] = () resume: Optional[Union[Any, dict[str, Any]]] = None goto: Union[Send, Sequence[Union[Send, str]], str] = () @@ -287,6 +289,8 @@ def __repr__(self) -> str: def _update_as_tuples(self) -> Sequence[tuple[str, Any]]: if isinstance(self.update, dict): return list(self.update.items()) + elif isinstance(self.update, BaseModel): + return list(self.update.model_dump().items()) elif isinstance(self.update, (list, tuple)) and all( isinstance(t, tuple) and len(t) == 2 and isinstance(t[0], str) for t in self.update