diff --git a/api/core/tools/entities/tool_entities.py b/api/core/tools/entities/tool_entities.py index ef96207fa7..2f25898f4e 100644 --- a/api/core/tools/entities/tool_entities.py +++ b/api/core/tools/entities/tool_entities.py @@ -120,6 +120,15 @@ class ToolInvokeMessage(BaseModel): raise ValueError("When 'stream' is True, 'variable_value' must be a string.") return value + + @field_validator("variable_name", mode="before") + def transform_variable_name(cls, value) -> str: + """ + The variable name must be a string. + """ + if value in ["json", "text", "files"]: + raise ValueError(f"The variable name '{value}' is reserved.") + return value class MessageType(Enum): TEXT = "text"