fix(mcp): await restart before rebinding the requesting agent - #930
fix(mcp): await restart before rebinding the requesting agent#930breedx wants to merge 3 commits into
Conversation
Keep materialized connector objects/status during manager refresh. Cancel registered lifecycle tasks under the registry lock, then drain outside it with a five-second deadline. Retain ownership on incomplete cleanup and deduplicate the shutdown callback. Restart ordering and pending startup ownership remain separate concerns.
|
The awaited restart and retained-owner regressions pass all upstream CI checks. Full macOS suite: 7,834 passed, 14 skipped, 28 warnings; quality and Windows encoding checks pass. This remains a dependent draft: merge #924 first, then refresh/requalify this incremental restart proposal. CI used Python 3.14.7 despite the 3.13 label; local qualification used 3.13.13. The existing stream callback warning remains here and is independently addressed by #929. Other warning categories (plugin httpx deprecations, SQLite resources, deprecated config APIs and unrelated test coroutines) were inspected, not suppressed; not every CI warning has an independent base reproduction. No release-qualification claim. Run: https://github.com/mpfaffenberger/code_puppy/actions/runs/34231192129 |
/mcp restartcurrently reports success and rebuilds the agent while the old connector is still stopping and its replacement is only scheduled. Await the actual stop, replacement and startup before rebinding the requesting agent, and distinguish failures from completed restarts.Dependency and related work
Depends on #924; do not merge before it. This branch contains #924's unchanged lifecycle commit plus two restart commits. The incremental restart diff is
eb11d855..3fa8db37.The dependency is behavioral: current main awaits lifecycle cleanup while holding the registry lock that cleanup itself needs. A direct restart port hangs on healthy shutdown; #924 provides the unlocked, bounded stop contract this workflow requires. #924 alone still allows the existing command to rebind before completion, demonstrated by the failing command control.
Given the plugin-first contribution guidance, please confirm the minimal existing command-handler seam before landing. This fixes an existing command; it adds no command or plugin architecture.
Change
Reload/remove and general concurrent lifecycle ownership are deliberately outside scope. A timeout bounds waiting, not a guarantee of process termination.
Validation
Linux / Python 3.13.13, PydanticAI 2.35.0, MCP 1.27.1, fastmcp-slim 3.4.7, core plugins 0.0.44. Dedicated environment, disposable HOME/XDG, blocked socket connect/DNS/bind; no dependency changes.
No live remote connector, multi-platform or release qualification is claimed. Public CI results will follow.