Skip to content

Python: Synchronize workflow preemption test startup - #8525

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
mainfrom
jpalvarezl-workflow-shutdown-test-flake
Sep 18, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
mainfrom
jpalvarezl-workflow-shutdown-test-flake

Conversation

@jpalvarezl

Copy link
Copy Markdown
Member

Motivation & Context

The workflow shutdown test can time out waiting for the inner agent to start, before shutdown is signalled. Both the shutdown and cancellation tests currently impose a one-second deadline on workflow startup as well as on preemption. Startup includes checkpoint storage work and should not be measured as shutdown or cancellation latency.

Separate readiness synchronization from the post-signal deadline so these tests exercise interruption of an already-blocked call without requiring startup to finish within one second.

Description & Review Guide

  • What are the major changes? Signal readiness from the mock stream immediately before it waits on the unset gate. Share a helper that waits for readiness or early handler completion, surfaces early failures, and cancels/drains its pending tasks and closes the handler on exit. Startup remains bounded by the existing pytest test timeout.
  • What is the impact of these changes? Test-only synchronization changes for shutdown and cancellation. Both one-second post-signal deadlines and the existing response/recovery assertions remain. Additional assertions verify that the blocked inner call was cancelled before test cleanup runs. Production behavior is unchanged.
  • What do you want reviewers to focus on? The readiness boundary, prompt propagation of startup failures, task cleanup, and ensuring cleanup cannot satisfy the preemption assertions on behalf of the handler.

Related Issue

N/A - small test-only correction; no linked issue.

Contribution Checklist

The affected response tests, test type checks, and changed-file hooks pass locally. Full CI is pending, and existing test dependency warnings remain.

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Wait for the inner stream to block before signalling shutdown or cancellation, independently of the retained preemption deadline. Drain pending test tasks and verify that the blocked call is cancelled before cleanup.

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

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.

🟢 Approval recommended

The focused test-only changes correctly isolate startup timing while preserving preemption assertions and cleanup.

Pull request overview

Separates workflow startup synchronization from preemption deadlines in shutdown and cancellation tests.

Changes:

  • Adds readiness and cancellation signals to the mock stream.
  • Centralizes pending-task and handler cleanup.
  • Preserves one-second post-signal deadlines and verifies actual cancellation.
File summaries
File Description
python/packages/foundry_hosting/tests/test_responses.py Synchronizes blocked-call startup and validates preemption cleanup.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: Python

Python / code-coverage/python

The overall line coverage in commit 92582ee in the jpalvarezl-workflow-... branch is 91%. Line coverage data for the main branch is not yet available.

Show a line coverage summary of the most covered files.
File main jpalvarezl-workflow-... 92582ee +/-
packages/core/a...ework/_tools.py 96%
packages/core/a...work/_skills.py 95%
packages/openai..._chat_client.py 94%
packages/core/a.../_compaction.py 94%
packages/core/a...ework/_types.py 93%
packages/core/a...ork/_vectors.py 93%
packages/core/a...bservability.py 93%
packages/core/a...amework/_mcp.py 92%
packages/ag-ui/...i/_agent_run.py 89%
packages/core/a...ork/security.py 89%

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): 92582ee738ac
Model: gpt-5.6-sol-fast

Overview

This test-only change moves readiness signaling to the point where the mock stream is actually entering its blocked call, keeping workflow startup outside the one-second preemption deadline. The helper surfaces early handler completion, drains its tasks, closes the handler, and the tests assert cancellation before helper cleanup can cause it. No publishable correctness, architectural, or security risk remains after reconciliation.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Merged via the queue into main with commit 8b29709 Sep 18, 2026
52 of 53 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the jpalvarezl-workflow-shutdown-test-flake branch September 18, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants