Repository navigation
Stop FastMCP callable caches from retaining dropped tools - #6147
Conversation
Fixes PrefectHQ#6115 Generated with OpenAI Codex. Co-authored-by: hanhyperfx <331364095+hanhyperfx@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Automated review by the FastMCP triage reviewer bot.
Changing FastMCP's own callable caches fixes the retention of removed tools' closures, without lifecycle workarounds. The earlier concern about functools.partial doesn't hold: partials have a writable __dict__ and support weak references. No changes requested.
Closures are fully released only once the uncalled-for caches are cleared too, which is outside this PR.
Checks
Reviewed at 4d4bea0. Nine lifetime tests fail on main and all 12 pass here, plus 200 neighboring tests. Client checks across tools, prompts, resources and templates agree.
Generated by Claude Code
|
At the reviewed head |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Revert "fix: preserve referenced schema definitions (#5588)" This reverts commit 5f1d152. * Revert "fix(server): rebuild tool argument errors instead of echoing pydantic's (#6107)" This reverts commit 8fba5f7. * Revert "Advertise the MCP Apps extension only when the server serves an app (#5062)" This reverts commit b89222b. * Revert "fix(tasks): retain results after tool removal (#5507)" This reverts commit 711575a. * Revert "fix(client): Prevent stale ClientGroup refreshes from replacing newer routes (#5543)" This reverts commit 365d5d2. * Revert "fix(prompts): honor field aliases when rendering prompts (#5836)" This reverts commit a450fd8. * Revert "Stop FastMCP callable caches from retaining dropped tools (#6147)" This reverts commit 713f247. * Revert "feat(auth): Add KeystoneTokenVerifier (#6264)" This reverts commit c33f3de. * Revert "fix(json-schema): keep x-unsupported-pattern when a format is set (#5731)" This reverts commit dc9849d. * Revert "Roll back the tool stamp when a tool registration is rejected (#5798)" This reverts commit d6566c5. * Revert "fix(server): validate cursors when pagination is disabled (#6045)" This reverts commit 4917bee. * Revert "Keep constraints on scalar schema references (#6041)" This reverts commit e5176c9.
FastMCP's process-wide callable caches retained tool closures after their servers were dropped, including the captured per-user data. Store wrapper and adapter metadata on the function or bound instance instead, so references between a callable and its cached values can be collected together. Callables that cannot own this metadata run uncached; ordinary type adapters keep the existing bounded cache. Runtime cache entries are discarded when a tool function is pickled for a task.
This fixes the FastMCP-owned retention in #6115. The independent signature and parameter caches in
uncalled-forstill retain functions until released there; that remaining dependency issue is tracked in chrisguidry/uncalled-for#21. The lifecycle regression isolates those third-party caches and does not claim that a full application using the current dependency has no remaining retention.Fixes #6115
Co-authored-by: hanhyperfx 331364095+hanhyperfx@users.noreply.github.com
Generated with OpenAI Codex.