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: add missing is_byok to LLM error details (#10311)

cthomasf5d649fcd6e1
diff --git a/letta/llm_api/anthropic_client.py b/letta/llm_api/anthropic_client.py
index 9587eb9c7..63e2817e9 100644
--- a/letta/llm_api/anthropic_client.py
+++ b/letta/llm_api/anthropic_client.py
@@ -1099,12 +1099,14 @@ class AnthropicClient(LLMClientBase):
details={
"status_code": e.status_code if hasattr(e, "status_code") else None,
"transient": True,
+ "is_byok": is_byok,
},
)
if "overloaded" in error_str:
return LLMProviderOverloaded(
message=f"Anthropic API is overloaded: {str(e)}",
code=ErrorCode.INTERNAL_SERVER_ERROR,
+ details={"is_byok": is_byok},
)
logger.warning(f"[Anthropic] Internal server error: {str(e)}")
return LLMServerError(
@@ -1113,6 +1115,7 @@ class AnthropicClient(LLMClientBase):
details={
"status_code": e.status_code if hasattr(e, "status_code") else None,
"response": str(e.response) if hasattr(e, "response") else None,
+ "is_byok": is_byok,
},
)
diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.py
index 4ef2d6ede..d36ae151f 100644
--- a/letta/llm_api/openai_client.py
+++ b/letta/llm_api/openai_client.py
@@ -332,8 +332,6 @@ class OpenAIClient(LLMClientBase):
if messages[0].role != "system":
raise RuntimeError(f"First message is not a system message, instead has role {messages[0].role}")
- from letta.schemas.letta_message_content import TextContent
-
system_message = messages[0].model_copy(deep=True)
system_message.content = [TextContent(text=system)]
return [system_message, *messages[1:]]
@@ -1291,7 +1289,7 @@ class OpenAIClient(LLMClientBase):
return LLMBadRequestError(
message="Upstream endpoint returned HTML error (400 Bad Request). This usually indicates the configured API endpoint is not an OpenAI-compatible API or the request was rejected by a load balancer.",
code=ErrorCode.INVALID_ARGUMENT,
- details={"raw_body_preview": error_str[:500]},
+ details={"raw_body_preview": error_str[:500], "is_byok": is_byok},
)
error_code = None