fix(mcp): preserve nullable schema coercion

This commit is contained in:
Pony.Ma
2026-04-28 12:25:10 +08:00
committed by Teknium
parent 1350d12b0b
commit aa94883288
4 changed files with 66 additions and 5 deletions

View File

@@ -2441,6 +2441,7 @@ def _normalize_mcp_input_schema(schema: dict | None) -> dict:
]
if len(non_null) == 1 and len(non_null) != len(variants):
replacement = dict(non_null[0]) if isinstance(non_null[0], dict) else {}
replacement.setdefault("nullable", True)
for meta_key in ("title", "description", "default", "examples"):
if meta_key in stripped and meta_key not in replacement:
replacement[meta_key] = stripped[meta_key]