6161import temporalio .workflow
6262from temporalio .nexus ._util import ServiceHandlerT
6363
64+ from .api .failure .v1 .message_pb2 import Failure
6465from .types import (
6566 AnyType ,
6667 CallableAsyncNoParam ,
@@ -897,11 +898,17 @@ def workflow_get_current_details(self) -> str: ...
897898 @abstractmethod
898899 def workflow_set_current_details (self , details : str ): ...
899900
901+ @abstractmethod
902+ def workflow_has_last_completion_result (self ) -> bool : ...
903+
900904 @abstractmethod
901905 def workflow_last_completion_result (
902906 self , type_hint : Optional [Type ]
903907 ) -> Optional [Any ]: ...
904908
909+ @abstractmethod
910+ def workflow_previous_run_failure (self ) -> Optional [BaseException ]: ...
911+
905912
906913_current_update_info : contextvars .ContextVar [UpdateInfo ] = contextvars .ContextVar (
907914 "__temporal_current_update_info"
@@ -1044,6 +1051,13 @@ def get_current_details() -> str:
10441051 return _Runtime .current ().workflow_get_current_details ()
10451052
10461053
1054+ def has_last_completion_result () -> bool :
1055+ """Get the last completion result of the workflow. This be None if there was
1056+ no previous completion or the result was None
1057+ """
1058+ return _Runtime .current ().workflow_has_last_completion_result ()
1059+
1060+
10471061@overload
10481062def get_last_completion_result () -> Optional [Any ]: ...
10491063
@@ -1053,14 +1067,18 @@ def get_last_completion_result(type_hint: Type[ParamType]) -> Optional[ParamType
10531067
10541068
10551069def get_last_completion_result (type_hint : Optional [Type ] = None ) -> Optional [Any ]:
1056- """Get the current details of the workflow which may appear in the UI/CLI.
1057- Unlike static details set at start, this value can be updated throughout
1058- the life of the workflow and is independent of the static details.
1059- This can be in Temporal markdown format and can span multiple lines.
1070+ """Get the last completion result of the workflow. This be None if there was
1071+ no previous completion or the result was None. has_last_completion_result()
1072+ can be used to differentiate.
10601073 """
10611074 return _Runtime .current ().workflow_last_completion_result (type_hint )
10621075
10631076
1077+ def get_previous_run_failure () -> Optional [BaseException ]:
1078+ """Get the last failure of the workflow."""
1079+ return _Runtime .current ().workflow_previous_run_failure ()
1080+
1081+
10641082def set_current_details (description : str ) -> None :
10651083 """Set the current details of the workflow which may appear in the UI/CLI.
10661084 Unlike static details set at start, this value can be updated throughout
0 commit comments