← Back to Pull requests

workflow: report whether the sidecar staged an operation #1354

Closed
unknown closed this pull request without merging on Nov 06, 2026 15:56 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 08:19 UTC
Author

Why

dapr/dapr#10909 and dapr/dapr#10910 add the WorkflowsStagedOperations preview. With it on, a sidecar with no workflow worker connected still accepts start, raise event, terminate, suspend, resume and rerun. It saves them and runs them once a worker connects. Today the caller gets the same OK as for an operation that ran, so it can't tell the two apart.

dapr/durabletask-protobuf#60 (merged) adds bool staged to those six responses. dapr/durabletask-go#147 (merged) shows it to Go callers. This PR does the same for Python. The sidecar side that sets the field is dapr/dapr#11061.

What

Protos. The vendored durabletask stubs are regenerated from durabletask-protobuf caf5cc1d (the #60 merge commit) with tools/regen_durabletask_protos.sh and the pinned grpcio-tools==1.81.1 / mypy-protobuf==5.0.0. Regenerating at the old commit first gave byte-identical files, so the diff is only the proto change. The new recorded commit also carries dapr/durabletask-protobuf#58, which adds parentExecutionId to backend_service.proto. That shows up in backend_service_pb2. The SDK does not use that service. I kept it so the stubs match PROTO_SOURCE_COMMIT_HASH.

Client. No existing method changes its signature or return value. Each of the six operations gets a _with_result variant on both the sync and the async DaprWorkflowClient:

| Method | Returns |
|---|---|
| schedule_new_workflow_with_result | WorkflowScheduleResult(instance_id, staged) |
| raise_workflow_event_with_result | WorkflowOperationResult(staged) |
| terminate_workflow_with_result | WorkflowOperationResult(staged) |
| pause_workflow_with_result | WorkflowOperationResult(staged) |
| resume_workflow_with_result | WorkflowOperationResult(staged) |
| rerun_workflow_from_event_with_result | WorkflowRerunResult(new_instance_id, staged) |

The three result types are frozen dataclasses, exported from dapr.ext.workflow. staged is false when the operation ran at once, and on sidecars that never stage. Purge is never staged, so it has no variant. schedule_new_workflow_with_result leaves out the deprecated reuse_id_policy.

result = client.schedule_new_workflow_with_result(my_workflow, input=data)
if result.staged:
    print(f'{result.instance_id} will start once a worker connects')

The vendored engine clients (TaskHubGrpcClient, AsyncTaskHubGrpcClient) get matching _with_result methods that return the response proto. The plain engine methods now call them and drop the flag, as in durabletask-go#147.

Why separate methods. Four of the existing methods return None and two return a str. Returning a result object from them would change their return types. A keyword flag that switches the return type needs @overload on every method and is easy to misread. Separate methods keep old callers as they are and give new callers a typed result. The names follow Go's ...WithResult methods so the SDKs read alike.

Docs: dapr/ext/workflow/AGENTS.md lists the new methods and types. No example is added, because none can show staged=True until a released runtime sets it.

Tests

tests/ext/workflow/test_workflow_staged.py starts a fake sidecar on a real local gRPC server. It answers each of the six calls with staged true, then false, and checks the result of every _with_result method, for the sync and async clients. It also checks that the plain methods still return what they did, and that both kinds of method send the same request.

Commands run, all on Python 3.12, after uv sync --frozen --all-packages --group dev:

  • uv run ruff check --fix && uv run ruff format: all checks passed, no changes left.

  • uv run mypy: no issues found in 231 source files.

  • uv run pytest tests -m "not e2e" --ignore=tests/integration --ignore=tests/examples --import-mode=importlib -o faulthandler_timeout=300 (the CI test command, without coverage): 2247 passed, 41 deselected.

  • uv run python -m unittest discover ./tests/ext/workflow: 252 tests, OK.
  • I did not run tests/examples or tests/integration. They need a Dapr runtime, and no released runtime sets staged yet.

    🤖 Generated with Claude Code

    Diff: 529 lines (+396 / -133) across 6 files Reviewer: sicoyle Review duration: 456m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 529 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.375
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1354"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%