Skip to content

fix(sdk): keep replay status in virtual children - #998

Open
yaythomas wants to merge 1 commit into
mainfrom
fix/virtual-child-replay
Open

yaythomas wants to merge 1 commit into
mainfrom
fix/virtual-child-replay

Conversation

@yaythomas

Copy link
Copy Markdown
Contributor

Issue #, if available

Fixes #889, virtual child contexts exit replay early and omit resumed operation notifications.

Description of changes

A virtual child context never checkpoints itself. During replay, _replay_aware read the missing checkpoint at its id as new work and switched the context to NEW, both before the virtual child started and in the look-ahead after the operation before it. The child inherited NEW, so is_replaying() returned False inside it, replayed log lines repeated, and plugins got no on_operation_end for an inner operation that completed while the execution was suspended.

The check before the operation now keeps replay status for a virtual child, and _next_operation_exists() also checks the next operation's first inner operation, as the JS SDK has done since aws-durable-execution-sdk-js #697: keep replay mode active after a virtual context.

This is the fix and tests from PR #909: an earlier fix for this issue by @nandanadileep, which was closed before it merged. I removed an unused test-helper parameter and reworded one docstring sentence. It replaces PR #997: a second fix for this issue, which misses a virtual child that follows a replayed operation.

Design

  • Design note (rule 3): not needed. No public API changes.
  • Simpler options considered (rule 2): Changing only the check before the operation, as fix(sdk): keep replay status when a virtual child has inner history #997 does, misses a virtual child after a replayed operation, because the look-ahead after that operation has already switched to NEW. Using only the first-inner-id check in both places, which is the JS rule, switches to NEW at an empty virtual child that is the first operation in its context, so the replayed operations after it lose their notifications.
  • Root cause (rule 5): both checks treat a missing checkpoint at the next operation's id as new work, and a virtual child never has one.
  • Net change: +28 −6 lines in context.py, most of them comments. No public API members.

Assumptions

None about outside behavior. The change reads only checkpoint ids that the SDK itself generates.

Decisions not covered by the issue or the design note

  • After a replayed operation, a virtual child with no checkpoint at its first inner id, such as an empty one or one that starts with another virtual child, still switches the context to NEW. Covering it needs a recursive lookup, and JS has the same limit.
  • A new virtual child that is the first operation in a replaying context reports is_replaying() as True until its first inner operation. History cannot tell it from an empty virtual child that already ran, because neither leaves a checkpoint.
  • No e2e test. Unit tests with a real plugin cover this isolated fix.

Checklist

  • Every new branch has a test that fails without it (rule 4)
  • For a bug fix: the first commit adds a test that fails on the current code (rule 5). The new tests fail on main, for example with assert [False] == [True].
  • Every edited test expectation is listed in the description, with the reason (rule 5): none edited.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

A virtual child context never checkpoints itself. During replay, two
checks in _replay_aware read the missing checkpoint at its id as new
work and switched the context to NEW. One check runs before the
virtual child starts. The other is the look-ahead after the operation
that precedes it. The child inherited NEW, so is_replaying() returned
False inside it, replayed log lines repeated, and plugins got no
on_operation_end for an inner operation that completed while the
execution was suspended.

The check before the operation now keeps replay status for a virtual
child, and _next_operation_exists() also checks the next operation's
first inner operation, as the JS SDK does.

Fixes #889

Co-authored-by: Nandana Dileep <[email protected]>
@yaythomas
yaythomas deployed to ai-pr-review-runtime November 27, 2026 18:45 — with GitHub Actions Active
@yaythomas
yaythomas deployed to ai-pr-review-runtime November 27, 2026 18:45 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

No actionable findings in the PR changes or against CONTRIBUTING rules 1–9. Residual test risk: tests were inspected but not executed, as required by the review constraints.

Reviewed commit 25f801502a276947fc313c7ab0b55ef93508f361. Workflow run

This branch was successfully deployed

1 active deployment
ai-pr-review-runtime — 25f80150 Deployed Nov 27, 2026 by yaythomas via ai-pr-review / Codex review / Generate Codex review #3505
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.

[Bug]: Virtual child contexts exit replay early and omit resumed operation notifications

1 participant