Repository navigation
Advertise timeout cleanup and send the portable interruption marker - #381
Merged
Merged
Conversation
A worker with cooperative cancellation now lists the timeout_cleanup
capability and sends capability_manifest.timeout_cleanup =
{supported: true, minimum_protocol_version: "1.20", version: 1}, the
shape native Server admission accepts (server#1201).
When the exception object the runtime raised for the run's root
cause: timeout request escapes workflow code, uncaught or re-raised,
fail_workflow carries failure.interruption: "timeout_cleanup".
Constructed, wrapped and compensation failures and ordinary or explicit
cancellation requests stay ordinary failures. Workers without
cooperative cancellation advertise nothing and never send the marker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Python SDK worker side of deadline-triggered timeout cleanup, for durable-workflow/server#1201. It follows the portable contract in Workflow's
docs/architecture/timeout-cleanup.mdand mirrors sdk-php#481.What changes
Capability. A worker with negotiated cooperative cancellation lists
timeout_cleanupincapabilitiesand sendscapability_manifest.timeout_cleanup = {supported: true, minimum_protocol_version: "1.20", version: 1}. Nativeworker_supports()admits this shape. A worker without cooperative cancellation advertises nothing, and its registration is unchanged. Listingtimeout_cleanupwithoutcooperative_cancellationraisesValueError, the same way the Nexus capability is checked.Marker. When the delivered
WorkflowTimeoutCleanupRequestedescapes workflow code,fail_workflowcarriesfailure: {interruption: "timeout_cleanup"}. That covers uncaught, re-raised, and raised again bythrow_if_cancellation_requested(). The runtime remembers the exception objects it raised for a timeout request and matches the escaped exception by identity. It also requires the root context:cause: "timeout", matching request ID, no parent or scope origin, androot_workflow_run_idequal to the run. The class name alone never decides. These stay unmarked and record failed cleanup:WorkflowTimeoutCleanupRequestedraisedfromthe delivered onecause: "cancellation"requestReturning from cleanup still sends
complete_workflow.FailWorkflowgains an optionalinterruptionfield (defaultNone), so the change is additive. The worker drops the field when cooperative cancellation is not negotiated. The failure-report limiter keeps the top-levelfailurekey, and a test covers that.New internal
durable_workflow._timeout_cleanupholds the capability, the manifest entry and the marker rule. CHANGELOG (Unreleased) anddocs/cooperative-cancellation-design.mddescribe admission and the four outcomes.Tests
tests/test_timeout_cleanup.py(28 tests):timeout_cleanupwithout cooperative cancellation is refusedCompleteWorkflow; offline replay without a run ID does not markcooperative-timeout-cleanup-interruption-marker.json. Its history containsWorkflowTimeoutCleanupStarted, then delivery, shielded cleanup and re-raise, and the expected command isfail_workflowwith the marker. All test histories includeWorkflowTimeoutCleanupStartedand replay unchanged.python:3.12-bookworm: ruff and mypy are clean, andvalidate-regression-corpus.py --base-ref origin/mainpasses. The focused suites pass (47). The full local non-integration suite gives 7972 passed and 2 failed. The two failures are GIL-blocked prepared-local timing tests, which pass on rerun; the host load was about 40. CI is green on 3.10 through 3.15.Installed check against published native Server 3.29.0 (SQLite)
durableworkflow/server@sha256:a2f588ec34b0b3a5a1eb298ce53c0b823260f86cec7bb5c5cb3577dcc5df0127(3.29.0), with SQLite on tmpfs and the worker running from this branch's source.server_capabilities.timeout_cleanupis still unadvertised (null), as expected.timeout_cleanup_secondson a queue with only a non-cooperative Python worker422 timeout_cleanup_not_supportedWorkflowTimedOut,timeout_cleanup.outcome: completedWorkflowTimedOut,outcome: completedWorkflowTimedOut,outcome: completedRuntimeErrorWorkflowTimedOut,outcome: failedwithfailure_id, message ends "Timeout cleanup failed."raise RuntimeError(...) from interrupted)WorkflowTimedOut,outcome: failedwithfailure_idEach run recorded exactly one
WorkflowTimeoutCleanupStartedandfailure_category: timeout. Each run usedexecution_timeout_seconds: 40andtimeout_cleanup_seconds: 25, one run at a time. An earlier attempt with an 8-second allowance, concurrent runs and disk SQLite on the loaded shared host hitstorage_unavailable503s, and several runs recordedexpired. That is the Server enforcing the cleanup deadline, not an SDK outcome.What this does not do
timeout_cleanup_seconds.ADVERTISEDand the installed vectors 1 to 12.🤖 Generated with Claude Code