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: compaction on 413 from openai (#9263)

Ari Webb170886b8a82a
diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.py
index 8560d86b7..eb61ed332 100644
--- a/letta/llm_api/openai_client.py
+++ b/letta/llm_api/openai_client.py
@@ -1091,6 +1091,11 @@ class OpenAIClient(LLMClientBase):
# General API error catch-all
if isinstance(e, openai.APIStatusError):
logger.warning(f"[OpenAI] API status error ({e.status_code}): {str(e)}")
+ # Handle 413 Request Entity Too Large - request payload exceeds size limits
+ if e.status_code == 413:
+ return ContextWindowExceededError(
+ message=f"Request too large for OpenAI (413): {str(e)}",
+ )
# Map based on status code potentially
if e.status_code >= 500:
error_cls = LLMServerError