fix(mcp): stop leaking an unawaited watcher coroutine per stdio tool call (salvage #96044) - #96251
Closed
kshitijk4poor wants to merge 2 commits into
Closed
kshitijk4poor wants to merge 2 commits into
kshitijk4poor wants to merge 2 commits into
Conversation
…k probe The fast-fail gate probed the stdio child watcher by CALLING it — inspect.isawaitable(_watch_children()) — creating a fresh coroutine on every stdio MCP tool call that was never awaited (RuntimeWarning spam + gc churn). Inspect the function instead of invoking it. Salvaged (unique hunk only) from PR NousResearch#96044; the bundled _stdio_children_dead polarity fix was already on main via NousResearch#94339.
…function Follow-up to the salvaged NousResearch#96044 hunk: drop the 'or callable(...)' arm — callable(MagicMock) is True, which would have flipped stubbed sessions into the fast-fail race the surrounding comment explicitly routes to the plain-await path. inspect.iscoroutinefunction alone reproduces the old isawaitable(call) split exactly (real async def / AsyncMock -> race, MagicMock -> plain await) without creating the leaked coroutine.
kshitijk4poor
enabled auto-merge (rebase)
August 27, 2026 09:48
auto-merge was automatically disabled
August 27, 2026 20:04
Pull request was closed
kshitijk4poor
enabled auto-merge (rebase)
August 27, 2026 20:04
novnski
added a commit
to novnski/hermes-agent
that referenced
this pull request
Aug 28, 2026
Adopt reviewed ideas from upstream PRs NousResearch#96251, NousResearch#96498, NousResearch#96748, NousResearch#96884, and NousResearch#96885 with local integration tests. Co-authored-by: loulanyue <260355617@qq.com> Co-authored-by: 686f6c61 <github@00b.tech> Co-authored-by: ahrazzle <ahraz.arifuddin@gmail.com> Co-authored-by: Agi-Asi <Agi-Asi@users.noreply.github.com>
Contributor
fix(mcp): stop leaking an unawaited watcher coroutine per stdio tool call — correct leak fix
Non-blocking — minimal, precise. |
This was referenced Aug 30, 2026
bvisible
added a commit
to bvisible/hermes-agent
that referenced
this pull request
Sep 1, 2026
…ssifier 'Bonjour Nora' cost two serial LLM round-trips (classify, then the light-path completion): 2.8 s on a loaded Olares, measured 2026-09-01 07:49:29.39 → 07:49:32.15, before the desk even polled. A greeting, a thank-you, a 'how are you' or a farewell has one right answer per language: say it from a template (fr/de/it/en, vouvoiement), delivered exactly like the light path. Gate is stricter than the light path's — the message must be small talk and nothing else (residue ≤ 1 word), so 'Bonjour, qui es-tu ?' still gets the LLM. Also: point the mcp_tool.py marker at upstream PR NousResearch#96251 (our NousResearch#100110 was closed as its duplicate).
This was referenced Sep 1, 2026
Collaborator
|
Landed on main via #100920 (rebase-merge, your commits preserved as-authored: fix by @loulanyue, tests by @kshitijk4poor — main fe3e5dc). The branch here had gone stale against main so it was re-based in a fresh PR rather than pushed to. Thanks for carrying the salvage. |
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.
Summary
The stdio fast-fail gate no longer leaks an unawaited coroutine on every MCP stdio tool call: the
_watch_okprobe inspected awaitability by calling the child watcher (inspect.isawaitable(_watch_children())), creating a fresh never-awaited coroutine per call ("coroutine was never awaited" RuntimeWarning spam + GC churn). It now inspects the function without invoking it.Salvage of the unique hunk from #96044 by @loulanyue (authorship preserved). The other half of that PR — the
_stdio_children_deadpolarity fix — was already on main via #94339.Changes
tools/mcp_tool.py(@loulanyue): probe_watch_childrenwithout calling it. Our follow-up tightens the replacement toinspect.iscoroutinefunction(_watch_children)alone — the originally proposedor callable(...)arm would have flipped MagicMock-stubbed sessions into the fast-fail race (callable(MagicMock) is True), breaking the plain-await path the surrounding comment routes stubs to.Validation
Credit
Coroutine-leak find and fix by @loulanyue in #96044. Closes #96044 (its polarity half was superseded by #94339).
First report of the leak: @glupta in #95938 (also reported independently by @ilgo in #96030). @liuhao1024 shipped an equivalent earlier fix in #95939 (create-once-and-reuse shape) — see that PR for the credit note on why this shape was preferred.
Closes #95938. Closes #96030. Refs #96016.