You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Async-generator tools iterate after context-manager dependencies have closed #5399
An async-generator tool that uses an injected context-manager dependency gets the dependency closed before its first iteration. The call returns an MCP error (I/O operation on closed file) instead of payload. A regular async tool with the same dependency works.
Expected: the result contains payload. Actual: the call returns I/O operation on closed file.
Environment
FastMCP commit c3b81662d31aa003a3451a7dcc7e41d38f3baef8, MCP 2.0.0, Python 3.12.15, macOS 15.0.1 arm64. Reproduced with the in-memory client; no external services are involved.
The issue is that async-generator tools iterate after context-manager dependencies have closed. I'll investigate the root cause in the tool execution flow and add a regression test.
I'll start by reproducing the issue with a minimal async-generator tool that uses a context-manager dependency.
PR #5438 consolidates #5399 and #5400. It carries forward the production fix and two tests from #5402 and adds broader lifecycle regression coverage. The issue-link check is failing because I am not assigned to either issue. I saw the recent comment expressing interest in #5399, so I will not self-assign or claim it. Could a maintainer advise whether to assign me to #5400 and keep this PR focused there, transfer the additional tests to #5402, or close one PR? I can follow whichever path avoids duplicating work. This is a Codex-assisted change; the PR body discloses that assistance.
Activity
DawnofGenX commentedon Oct 4, 2026
I'd like to work on this.
The issue is that async-generator tools iterate after context-manager dependencies have closed. I'll investigate the root cause in the tool execution flow and add a regression test.
I'll start by reproducing the issue with a minimal async-generator tool that uses a context-manager dependency.
mikamikasuki commentedon Oct 4, 2026
PR #5438 consolidates #5399 and #5400. It carries forward the production fix and two tests from #5402 and adds broader lifecycle regression coverage. The issue-link check is failing because I am not assigned to either issue. I saw the recent comment expressing interest in #5399, so I will not self-assign or claim it. Could a maintainer advise whether to assign me to #5400 and keep this PR focused there, transfer the additional tests to #5402, or close one PR? I can follow whichever path avoids duplicating work. This is a Codex-assisted change; the PR body discloses that assistance.
fix: keep generator iteration inside dependency lifetime (PrefectHQ#5438
DawnofGenX commentedon Oct 7, 2026
Thanks for the pointer — I see #5438 consolidated this along with #5399/#5400/#5402. No action needed from me; I'm not pursuing this one.