You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OrchestrationContext.call_entity does not provide any way to specify type for expected output #90
The call_entity method currently returns Task[Unknown] that can break type-safety. Ideally, the call_entity method should provide a way to specify the type of the expected output (similar to how call_activity does (using TOutput) -
@abstractmethoddefcall_activity(self, activity: Union[Activity[TInput, TOutput], str], *,
input: Optional[TInput] =None,
retry_policy: Optional[RetryPolicy] =None,
tags: Optional[dict[str, str]] =None) ->Task[TOutput]:
"""Schedule an activity for execution. Parameters ---------- activity: Union[Activity[TInput, TOutput], str] A reference to the activity function to call. input: Optional[TInput] The JSON-serializable input (or None) to pass to the activity. retry_policy: Optional[RetryPolicy] The retry policy to use for this activity call. tags: Optional[dict[str, str]] Optional tags to associate with the activity invocation. Returns ------- Task A Durable Task that completes when the called activity function completes or fails. """pass@abstractmethoddefcall_entity(self, entity: EntityInstanceId,
operation: str,
input: Optional[TInput] =None) ->Task:
"""Schedule entity function for execution. Parameters ---------- entity: EntityInstanceId The ID of the entity instance to call. operation: str The name of the operation to invoke on the entity. input: Optional[TInput] The optional JSON-serializable input to pass to the entity function. Returns ------- Task A Durable Task that completes when the called entity function completes or fails. """pass
The reason that knowing the output type is difficult is that it is determined based on the entity name from the entity ID, and the operation. For class-based entities, users are free to define operations as separate methods on the entity with different input and output types - we would need a way to dynamically retrieve the type-hinting for class methods which as far as I can tell, is not possible in time for static type checking.
For now, I'll type-hint the Task as Task[Any] so the compiler stops complaining, but it'll be up to the user to check and cast back to the actual return type as needed.
Note: Here's a draft PR for slightly better behavior than what we have today (details in description) but there are several issues we will need to work out before deciding whether to merge. #103
Activity
andystaples commentedon Jan 12, 2026
The reason that knowing the output type is difficult is that it is determined based on the entity name from the entity ID, and the operation. For class-based entities, users are free to define operations as separate methods on the entity with different input and output types - we would need a way to dynamically retrieve the type-hinting for class methods which as far as I can tell, is not possible in time for static type checking.
For now, I'll type-hint the Task as Task[Any] so the compiler stops complaining, but it'll be up to the user to check and cast back to the actual return type as needed.
andystaples commentedon Jan 12, 2026
Note: Here's a draft PR for slightly better behavior than what we have today (details in description) but there are several issues we will need to work out before deciding whether to merge. #103
andystaples commentedon Jul 16, 2026
Released in v1.7.0