What would you like?
Expose the current operation attempt number to user code through the Python operation context.
For example, when processing an order, a workflow may need to place a backorder with one of several suppliers in preference order. If the first supplier is unavailable, the next retry should try the next supplier. The available suppliers and number of suppliers can vary by order, and this is much easier to implement if the step/check function can read the current attempt count from its context.
Today the SDK already tracks the attempt internally for retries, logging, plugins, and wait_for_condition strategies, but the attempt is not directly available on OperationContext, StepContext, or WaitForConditionCheckContext.
Possible Implementation
Extend OperationContext with an additional integer field, for example:
@dataclass(frozen=True)
class OperationContext:
logger: LoggerInterface
attempt: int
Then populate it when constructing concrete operation contexts such as StepContext and WaitForConditionCheckContext, using the same current-attempt value already passed to the replay-aware logger and wrap_user_function.
Open question: should this be named attempt, attempt_count, or another Python API name that matches the rest of the SDK conventions?
Is this a breaking change?
No
Does this require an RFC?
No
Additional Context
This mirrors the JavaScript SDK feature request: aws/aws-durable-execution-sdk-js#502
What would you like?
Expose the current operation attempt number to user code through the Python operation context.
For example, when processing an order, a workflow may need to place a backorder with one of several suppliers in preference order. If the first supplier is unavailable, the next retry should try the next supplier. The available suppliers and number of suppliers can vary by order, and this is much easier to implement if the step/check function can read the current attempt count from its context.
Today the SDK already tracks the attempt internally for retries, logging, plugins, and wait_for_condition strategies, but the attempt is not directly available on
OperationContext,StepContext, orWaitForConditionCheckContext.Possible Implementation
Extend
OperationContextwith an additional integer field, for example:Then populate it when constructing concrete operation contexts such as
StepContextandWaitForConditionCheckContext, using the same current-attempt value already passed to the replay-aware logger andwrap_user_function.Open question: should this be named
attempt,attempt_count, or another Python API name that matches the rest of the SDK conventions?Is this a breaking change?
No
Does this require an RFC?
No
Additional Context
This mirrors the JavaScript SDK feature request: aws/aws-durable-execution-sdk-js#502