Repository navigation
Commit 84d4027
authored
Python: Account for intercepted messages when stopping the runtime (#14656)
### 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`.
- Before the fix, runtime/serialization plus the new regression: 9
failed, 23 passed on both Python 3.12.14 and 3.13.15. Each failure
reaches the idle-stop deadline.
- After the fix, runtime, orchestration, and group-chat suites: 175
passed, 1 skipped on each interpreter. The skip is an existing upstream
timing-related skip.
- These tests use normal complete-package imports and upstream
`tests/conftest.py`. No namespace bootstrap, model API, or external
service is involved.
- Ruff 0.13.1 lint/format, Python AST, whitespace checks, and clean
patch application pass.
- The entire repository suite, type checking, and pinned pre-commit
hooks have not run. Local command-line network access is blocked, so the
repository's Ruff 0.9.6 hook and other missing hook dependencies could
not be installed.
Command, from `python/`:
`python -m pytest tests/unit/agents/runtime
tests/unit/agents/orchestration tests/unit/agents/test_group_chat -rs`
### Contribution Checklist
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the complete pre-submission checks pass
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
### AI assistance
OpenAI Codex assisted with source inspection, the regression tests, the
six-line fix, and local verification.1 parent ecb80bd commit 84d4027
2 files changed
Lines changed: 100 additions & 0 deletions
File tree
- python
- semantic_kernel/agents/runtime/in_process
- tests/unit/agents/runtime
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
566 | 567 | | |
567 | 568 | | |
568 | 569 | | |
| |||
574 | 575 | | |
575 | 576 | | |
576 | 577 | | |
| 578 | + | |
577 | 579 | | |
578 | 580 | | |
579 | 581 | | |
| |||
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
| 608 | + | |
606 | 609 | | |
607 | 610 | | |
608 | 611 | | |
| |||
613 | 616 | | |
614 | 617 | | |
615 | 618 | | |
| 619 | + | |
616 | 620 | | |
617 | 621 | | |
618 | 622 | | |
| |||
629 | 633 | | |
630 | 634 | | |
631 | 635 | | |
| 636 | + | |
632 | 637 | | |
633 | 638 | | |
634 | 639 | | |
| |||
640 | 645 | | |
641 | 646 | | |
642 | 647 | | |
| 648 | + | |
643 | 649 | | |
644 | 650 | | |
645 | 651 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
0 commit comments