From da6b55aa38b4941751cd990f5869727f841d37d7 Mon Sep 17 00:00:00 2001 From: Andy Staples Date: Thu, 6 Nov 2025 10:41:40 -0700 Subject: [PATCH] Reduce entity context exposure --- durabletask/worker.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/durabletask/worker.py b/durabletask/worker.py index 09f6559..d532cea 100644 --- a/durabletask/worker.py +++ b/durabletask/worker.py @@ -776,7 +776,7 @@ class _RuntimeOrchestrationContext(task.OrchestrationContext): _generator: Optional[Generator[task.Task, Any, Any]] _previous_task: Optional[task.Task] - def __init__(self, instance_id: str, registry: _Registry, entity_context: OrchestrationEntityContext): + def __init__(self, instance_id: str, registry: _Registry): self._generator = None self._is_replaying = True self._is_complete = False @@ -791,7 +791,7 @@ def __init__(self, instance_id: str, registry: _Registry, entity_context: Orches self._current_utc_datetime = datetime(1000, 1, 1) self._instance_id = instance_id self._registry = registry - self._entity_context = entity_context + self._entity_context = OrchestrationEntityContext(instance_id) self._version: Optional[str] = None self._completion_status: Optional[pb.OrchestrationStatus] = None self._received_events: dict[str, list[Any]] = {} @@ -1225,7 +1225,6 @@ def __init__(self, registry: _Registry, logger: logging.Logger): self._logger = logger self._is_suspended = False self._suspended_events: list[pb.HistoryEvent] = [] - self._entity_state: Optional[OrchestrationEntityContext] = None def execute( self, @@ -1233,14 +1232,12 @@ def execute( old_events: Sequence[pb.HistoryEvent], new_events: Sequence[pb.HistoryEvent], ) -> ExecutionResults: - self._entity_state = OrchestrationEntityContext(instance_id) - if not new_events: raise task.OrchestrationStateError( "The new history event list must have at least one event in it." ) - ctx = _RuntimeOrchestrationContext(instance_id, self._registry, self._entity_state) + ctx = _RuntimeOrchestrationContext(instance_id, self._registry) try: # Rebuild local state by replaying old history into the orchestrator function self._logger.debug(