Skip to content

Add orchestration send_event support - #225

Merged
andystaples merged 6 commits into
microsoft:mainfrom
andystaples:andystaples-add-orchestration-send-event
Jul 29, 2026
Merged

Add orchestration send_event support#225
andystaples merged 6 commits into
microsoft:mainfrom
andystaples:andystaples-add-orchestration-send-event

Conversation

@andystaples

Copy link
Copy Markdown
Contributor

Summary

  • add synchronous OrchestrationContext.send_event(instance_id, event_name, *, data=None) for one-way orchestration-to-orchestration events
  • emit deterministic SendEventAction records using the configured data converter and reconcile EventSent history during replay using .NET-compatible event-name matching
  • record and deliver sent events in the in-memory backend without duplicate replay delivery, while dropping events for missing or terminal targets
  • cover action creation, validation, custom and externalized payloads, replay nondeterminism, legacy entity-history compatibility, and end-to-end delivery

Validation

  • python -m nox -s ci -- 3.14
  • python -m nox -R -s core_tests-3.14 -- tests\durabletask\test_orchestration_executor.py tests\durabletask\test_orchestration_e2e.py tests\durabletask\test_large_payload.py -q
  • python -m nox -R -s lint
  • python -m nox -R -s typecheck_core-3.10

Closes #32

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
Copilot AI review requested due to automatic review settings July 28, 2026 21:04

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 orchestration-to-orchestration one-way event sending to the core Durable Task Python SDK, including deterministic action emission and replay reconciliation, plus in-memory backend delivery behavior and coverage.

Changes:

  • Introduces OrchestrationContext.send_event(instance_id, event_name, *, data=None) and emits SendEventAction records using the configured DataConverter.
  • Reconciles EventSent history during replay (including case-insensitive event-name matching) and wires action-type name resolution for sendEvent.
  • Extends the in-memory backend to persist EventSent history and deliver/drop sent events safely without duplicate replay delivery; adds unit/E2E/large-payload tests and a changelog entry.

Reviewed changes

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

Show a summary per file
File Description
tests/durabletask/test_orchestration_executor.py Adds unit tests covering send-event action creation, converter usage, validation, and replay nondeterminism behavior.
tests/durabletask/test_orchestration_e2e.py Adds E2E coverage for orchestration-to-orchestration event delivery and replay-safe non-duplication behavior.
tests/durabletask/test_large_payload.py Verifies large send-event payloads are externalized.
durabletask/worker.py Implements send_event, reconciles EventSent during replay, and maps sendEvent actions to the correct method name.
durabletask/testing/in_memory_backend.py Records EventSent history and delivers/drops send-event actions in the in-memory backend.
durabletask/task.py Declares the public send_event API on OrchestrationContext.
durabletask/internal/helpers.py Adds helpers to build SendEventAction and enrich EventSent history with an event name.
CHANGELOG.md Documents the new OrchestrationContext.send_event() API under Unreleased/ADDED.

Comment thread durabletask/task.py Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
Copilot AI review requested due to automatic review settings July 28, 2026 21:13

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

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

Comment thread durabletask/worker.py
Comment thread durabletask/task.py Outdated
Comment thread durabletask/testing/in_memory_backend.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
Copilot AI review requested due to automatic review settings July 29, 2026 03:53

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
Copilot AI review requested due to automatic review settings July 29, 2026 14:52

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

durabletask/worker.py:3006

  • When reconciling legacy entity EventSent history, a target-instance mismatch currently raises _get_wrong_action_type_error(..., task.get_name(ctx.send_event), ...), which produces a misleading NonDeterminismError message (it reports send_event even though the pending action is an entity call/signal/lock). This makes debugging replay mismatches harder.

Consider raising a NonDeterminismError that explicitly describes the instanceId mismatch and uses _get_method_name_for_action(action) (entity method) for the method name.

                    if entity_target != event.eventSent.instanceId:
                        raise _get_wrong_action_type_error(
                            event.eventId,
                            task.get_name(ctx.send_event),
                            action,
                        )

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 56111c85-99ce-477c-a97f-c2d57a162a55
Copilot AI review requested due to automatic review settings July 29, 2026 15:28
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 56111c85-99ce-477c-a97f-c2d57a162a55

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 29, 2026 15:32

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

durabletask/worker.py:3375

  • The NonDeterminismError text in this function uses "it's history" (contraction) instead of the possessive "its history"; this is user-facing and shows up in replay mismatch failures.
    )

@berndverst berndverst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-reviewed at c09493d. Target-instance changes now fail replay deterministically, the public ABC remains backward compatible, and terminal event cleanup remains correct.

@andystaples
andystaples merged commit 033179b into microsoft:main Jul 29, 2026
23 checks passed
@andystaples
andystaples deleted the andystaples-add-orchestration-send-event branch July 29, 2026 16:15
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.

Missing implementation for send_event

3 participants