Repository navigation
Python: preserve background execution identity across completion waits - #9442
Conversation
Signed-off-by: CorgiBoyG <111257566+CorgiBoyG@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in the scoped fix or regression coverage; tests were not executed.
0 open findings
What changed in this PR
Fixes #9441 by preserving background execution identity across completion waits, without changing task-retention or session-release policies.
Changes:
- Finalizes the exact execution observed by the waiter.
- Guards runtime removal and persistence against newer continuations.
- Adds 12 continuation-race cases and one concurrent-waiter test.
| File | Description |
|---|---|
| python/packages/core/tests/core/test_harness_background_agents.py | Adds deterministic continuation-race and concurrent-waiter coverage. |
| python/packages/core/agent_framework/_harness/_background_agents.py | Preserves execution identity and protects newer continuation state. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Eduard van Valkenburg (@eavanvalkenburg), this PR is now ready for review. CI completed with 33 successful checks, 21 skipped checks, and no failures or pending checks; all required checks passed. The Python test matrix, code quality, coverage, API compatibility, and CLA checks passed. The fix remains scoped to the wait/continuation execution-identity race in #9441, with twelve deterministic continuation cases and one concurrent-waiter regression. The tested commit remains The direction-confirmation request in #9441 is still pending, so the corresponding checklist item remains unchecked. Could you review the scoped approach when you have time? Thank you. |
Eduard van Valkenburg (eavanvalkenburg)
left a comment
There was a problem hiding this comment.
Reviewed the background-task completion race fix and its continuation/concurrent-waiter coverage. The identity checks prevent a stale waiter from removing or persisting over the current execution.
Motivation & Context
A background completion waiter can resume after another caller has continued the same task ID. It recognizes the original execution as completed but previously looked up the task again by ID, potentially consuming the continuation instead. A running continuation raises
InvalidStateError; a finished continuation can be finalized or reported by the stale waiter.Description & Review Guide
Related Issue
Fixes #9441
This addresses a local wait/continuation race, separate from the task-retention work in #9387 and distributed-runtime work in #9040.
Ready for review after CI completed successfully. Maintainer confirmation of the scoped direction requested in #9441 remains pending.
Contribution Checklist