Skip to content

Add parent_instance_id to OrchestrationContext#168

Open
andystaples wants to merge 2 commits into
microsoft:mainfrom
andystaples:andystaples/add-parent-id
Open

Add parent_instance_id to OrchestrationContext#168
andystaples wants to merge 2 commits into
microsoft:mainfrom
andystaples:andystaples/add-parent-id

Conversation

@andystaples

Copy link
Copy Markdown
Contributor

Summary

Adds a parent_instance_id property to OrchestrationContext. For a sub-orchestration, it returns the instance ID of the orchestration that scheduled it; for a top-level orchestration, it returns None.

Changes

  • durabletask/task.py — new abstract parent_instance_id property on OrchestrationContext.
  • durabletask/worker.py_RuntimeOrchestrationContext implements the property, backed by _parent_instance_id, populated from executionStarted.parentInstance.orchestrationInstance.instanceId (guarded by HasField).
  • tests/durabletask/test_orchestration_executor.py — two new tests: a sub-orchestration exposes its parent's instance ID, and a top-level orchestration returns None.
  • CHANGELOG.md — added an entry under ## Unreleased.

Testing

  • python -m pytest tests/durabletask/test_orchestration_executor.py — all tests pass, including the two new ones.
  • flake8 clean on all changed files; no Pylance/type errors.
  • markdownlint clean on the changelog additions.

Copilot AI review requested due to automatic review settings July 2, 2026 21:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new parent_instance_id property to the Durable Task Python SDK’s OrchestrationContext, enabling orchestrator code to detect whether it is running as a sub-orchestration and, if so, identify the parent orchestration instance.

Changes:

  • Added OrchestrationContext.parent_instance_id as a new abstract property returning str | None.
  • Implemented the property in the runtime orchestration context and populated it from executionStarted.parentInstance.orchestrationInstance.instanceId when present.
  • Added tests covering both sub-orchestration and top-level orchestration behavior, and documented the new API in CHANGELOG.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
durabletask/task.py Introduces the new abstract parent_instance_id API on OrchestrationContext.
durabletask/worker.py Implements and populates parent_instance_id in _RuntimeOrchestrationContext during executionStarted processing.
tests/durabletask/test_orchestration_executor.py Adds unit tests validating parent_instance_id for sub-orchestrations and top-level orchestrations.
CHANGELOG.md Documents the new OrchestrationContext.parent_instance_id property under ## Unreleased.

Comment thread durabletask/worker.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants