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: prevent turn delimiters from leaking for baseten (#9881)

cthomas65908cf238c6
diff --git a/letta/llm_api/baseten_client.py b/letta/llm_api/baseten_client.py
index 740628482..81a18f63a 100644
--- a/letta/llm_api/baseten_client.py
+++ b/letta/llm_api/baseten_client.py
@@ -75,6 +75,10 @@ class BasetenClient(OpenAIClient):
for field in ("reasoning_content_signature", "redacted_reasoning_content", "omitted_reasoning_content"):
msg.pop(field, None)
+ # Special tokens are used as turn delimiters; stop generation before the model
+ # starts predicting the next turn (prevents "<|user|>" leaking into responses)
+ data["stop"] = ["<|user|>", "<|assistant|>", "<|observation|>"]
+
return data
@trace_method