diff --git a/letta/schemas/message.py b/letta/schemas/message.py index 65e5d84b..4881ab0e 100644 --- a/letta/schemas/message.py +++ b/letta/schemas/message.py @@ -670,6 +670,9 @@ class Message(BaseMessage): def add_xml_tag(string: str, xml_tag: Optional[str]): # NOTE: Anthropic docs recommends using tag when using CoT + tool use + if f"<{xml_tag}>" in string and f"" in string: + # don't nest if tags already exist + return string return f"<{xml_tag}>{string}