From 170886b8a82a2df6af0f1feeae727323633b217a Mon Sep 17 00:00:00 2001 From: Ari Webb Date: Tue, 3 Feb 2026 14:30:59 -0800 Subject: [PATCH] fix: compaction on 413 from openai (#9263) --- letta/llm_api/openai_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.py index 8560d86b..eb61ed33 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