Repository navigation
Python: Account for intercepted messages when stopping the runtime - #14656
Open
Kevin Dong (KevinAndrewDong) wants to merge 2 commits into
Open
Kevin Dong (KevinAndrewDong) wants to merge 2 commits into
Kevin Dong (KevinAndrewDong) wants to merge 2 commits into
Conversation
Mark send, publish, and response envelopes done when interception drops them or raises, so stop_when_idle can complete.
Cover send, publish, and response interception with both drop marker forms, exceptions, and normal pass-through using the real runtime.
Kevin Dong (KevinAndrewDong)
deployed
to
github-app-auth
October 24, 2026 00:36 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The six targeted completion calls preserve normal dispatch accounting, and the regression cases cover every affected stage and outcome with no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes queue completion accounting in the Python in-process agent runtime so intercepted messages do not leave stop_when_idle() waiting indefinitely.
Changes:
- Marks dequeued messages complete on all six drop and exception paths across send, publish, and response interception.
- Adds 12 parameterized regression cases covering both drop marker forms, exceptions, and normal pass-through.
| File | Description |
|---|---|
python/tests/unit/agents/runtime/test_intervention_queue.py |
Adds regression coverage for idle shutdown after interception. |
python/semantic_kernel/agents/runtime/in_process/in_process_runtime.py |
Completes queue accounting on terminal interception paths. |
Review effort: Balanced
Author
|
@microsoft-github-policy-service agree |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Dropping a message or raising from an intervention handler can leave
InProcessRuntime.stop_when_idle()waiting indefinitely. The runtime has removed the envelope from the queue, but its unfinished-task count is never decremented on those early-return paths.Description
Call
task_done()before returning from the six send, publish, and response interception branches that drop a message or handle an exception. Normal dispatch retains its existing completion accounting.Add 12 parameterized regression cases covering those three stages with a drop marker class, a drop marker instance, a raised exception, and normal pass-through.
Validation
Baseline:
483ffb487a33a1644886992d56599feae3b69b76.tests/conftest.py. No namespace bootstrap, model API, or external service is involved.Command, from
python/:python -m pytest tests/unit/agents/runtime tests/unit/agents/orchestration tests/unit/agents/test_group_chat -rsContribution Checklist
AI assistance
OpenAI Codex assisted with source inspection, the regression tests, the six-line fix, and local verification.