Add orchestration send_event support - #225
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
There was a problem hiding this comment.
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 emitsSendEventActionrecords using the configuredDataConverter. - Reconciles
EventSenthistory during replay (including case-insensitive event-name matching) and wires action-type name resolution forsendEvent. - Extends the in-memory backend to persist
EventSenthistory 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. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
There was a problem hiding this comment.
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 reportssend_eventeven 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
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 56111c85-99ce-477c-a97f-c2d57a162a55
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Re-reviewed at c09493d. Target-instance changes now fail replay deterministically, the public ABC remains backward compatible, and terminal event cleanup remains correct.
Summary
OrchestrationContext.send_event(instance_id, event_name, *, data=None)for one-way orchestration-to-orchestration eventsSendEventActionrecords using the configured data converter and reconcileEventSenthistory during replay using .NET-compatible event-name matchingValidation
python -m nox -s ci -- 3.14python -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 -qpython -m nox -R -s lintpython -m nox -R -s typecheck_core-3.10Closes #32