Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: openai illegal char in name check (#1971)

cthomas5b265edb7b47
diff --git a/letta/schemas/message.py b/letta/schemas/message.py
index 2c273bb6e..e12fcb0d3 100644
--- a/letta/schemas/message.py
+++ b/letta/schemas/message.py
@@ -2,6 +2,7 @@ from __future__ import annotations
import copy
import json
+import re
import uuid
import warnings
from collections import OrderedDict
@@ -700,9 +701,12 @@ class Message(BaseMessage):
else:
raise ValueError(self.role)
- # Optional field, do not include if null
+ # Optional field, do not include if null or invalid
if self.name is not None:
- openai_message["name"] = self.name
+ if bool(re.match(r"^[^\s<|\\/>]+$", self.name)):
+ warnings.warn(f"Using OpenAI with invalid 'name' field (name={self.name} role={self.role}).")
+ else:
+ openai_message["name"] = self.name
if parse_content_parts:
for content in self.content: