fix: sanitize MCP tool names for OpenAI

This commit is contained in:
whats2000
2025-06-07 13:46:35 +08:00
parent 2a212ae759
commit 4d0ddd7ff3
3 changed files with 30 additions and 13 deletions
+5
View File
@@ -976,3 +976,8 @@ def is_valid_image_file(file_data: bytes) -> bool:
return True
return False
def sanitize_tool_name(name: str) -> str:
"""Sanitize tool names for OpenAI compatibility."""
return re.sub(r"[^a-zA-Z0-9_-]", "_", name)