mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-20 12:34:17 +02:00
fix: prevent $defs mutation in Tool.from_tool transforms (#2493)
Deep copy parent_defs before passing to compress_schema to prevent mutation from affecting parent tool schemas when child tools hide parameters that remove all $ref usage.
This commit is contained in:
parent
256f376988
commit
d770a76c79
1 changed files with 3 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import inspect
|
|||
import warnings
|
||||
from collections.abc import Callable
|
||||
from contextvars import ContextVar
|
||||
from copy import deepcopy
|
||||
from dataclasses import dataclass
|
||||
from typing import Annotated, Any, Literal, cast
|
||||
|
||||
|
|
@ -620,7 +621,8 @@ class TransformedTool(Tool):
|
|||
"""
|
||||
|
||||
# Build transformed schema and mapping
|
||||
parent_defs = parent_tool.parameters.get("$defs", {})
|
||||
# Deep copy to prevent compress_schema from mutating parent tool's $defs
|
||||
parent_defs = deepcopy(parent_tool.parameters.get("$defs", {}))
|
||||
parent_props = parent_tool.parameters.get("properties", {}).copy()
|
||||
parent_required = set(parent_tool.parameters.get("required", []))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue