Add Durable Task middleware support
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 32/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
Research direction
Start by comparing the referenced .NET cross-SDK middleware specification and user guide, then locate the Python durable worker/app registration entry points. Define the orchestration and activity APIs, contexts, feature access, ordering, validation, and short-circuit behavior, and add the acceptance-criteria tests and documentation; entity middleware and wire changes are out of scope.
Written by the indexing model from the issue text.
Description
Summary
Track adding SDK-level Durable Task middleware support to the Python SDK, aligned with the .NET reference implementation.
Reference spec: https://github.com/microsoft/durabletask-dotnet/blob/feature/durable-task-middleware/doc/cross-sdk-middleware.md
.NET user guide: https://github.com/microsoft/durabletask-dotnet/blob/feature/durable-task-middleware/doc/durable-task-middleware.md
Motivation: https://github.com/Azure/azure-functions-durable-extension/issues/3054
The spec may shift until the .NET v1 implementation is merged. This issue is intended to track the Python design and implementation work so it can follow the same durable middleware contract with idiomatic API names.
Proposed shape
Names are illustrative, not final API commitments.
@app.orchestration_middleware
async def orchestration_middleware(ctx, next):
if not ctx.is_replaying:
ctx.logger.info("starting orchestration", extra={"instance_id": ctx.instance_id})
await next(ctx)
@app.activity_middleware
async def activity_middleware(ctx, next):
cached = await cache.try_get(ctx.name, ctx.input)
if cached is not None:
ctx.set_result(cached)
return
await next(ctx)
Design points to cover
- Decorator and/or builder registration APIs that are scoped to a worker/app instance.
- Registration ordering: first registered middleware runs outermost and unwinds last.
- Dataclass/protocol-style contexts that expose durable task name, instance ID, version/parent/tags where available, input, raw input where available, replay state for orchestrations, features, and result after
next. - A feature collection using type keys or well-known keys when runtime type identity is not the right Python abstraction.
- Orchestration middleware determinism guidance for replay, including replay-safe logging and avoiding
datetime.now,uuid.uuid4,random, file/network I/O, arbitraryasyncioawaits, and mutable process state. - Activity middleware short-circuiting through an explicit
set_resultAPI. - Host integration pattern for Azure Functions or other hosts to attach invocation context through features instead of durable middleware depending on host middleware internals.
Acceptance criteria
- Orchestration and activity middleware APIs are exposed at the durable worker/app level.
- Middleware executes in registration order and unwinds in reverse order.
- Orchestration middleware must call
next(ctx)exactly once when completing successfully; missing or duplicate calls are rejected where feasible. - Activity middleware can call
next(ctx)once or short-circuit only throughctx.set_result(...); duplicatenextis invalid. - Host-specific objects can be passed through features without serialization into durable history.
- Documentation covers replay determinism and the difference between durable middleware and host/Functions middleware.
- Tests cover registration ordering, context population, feature access, orchestration next-call validation, and activity short-circuiting.
- No wire protocol or protobuf changes are required.
- Entity middleware is out of scope for v1.
- Dominant language
- Python
- Stars
- 40
- Forks
- 33
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/durabletask-python
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
microsoft/durabletask-python#268 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
microsoft/durabletask-python#266 ·
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
microsoft/durabletask-python#249 ·
-
bug Functions Parity
Difficulty 5/5 Over a week Newbie friendliness 35/100
microsoft/durabletask-python#241 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/durabletask-python#234 ·
All issues in microsoft/durabletask-python
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·