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: make sure structured outputs turned on for openai (#8669)

Sarah Woodersea36633cd559
diff --git a/letta/helpers/converters.py b/letta/helpers/converters.py
index 424dad81b..24cc2ab19 100644
--- a/letta/helpers/converters.py
+++ b/letta/helpers/converters.py
@@ -71,8 +71,24 @@ def serialize_llm_config(config: Union[Optional[LLMConfig], Dict]) -> Optional[D
def deserialize_llm_config(data: Optional[Dict]) -> Optional[LLMConfig]:
- """Convert a dictionary back into an LLMConfig object."""
- return LLMConfig(**data) if data else None
+ """Convert a dictionary back into an LLMConfig object.
+
+ Handles default value for 'strict' based on provider:
+ - OpenAI: defaults to True
+ - Others (Anthropic, etc.): defaults to False
+ """
+ if not data:
+ return None
+
+ # Handle strict mode default based on provider.
+ # OpenAI supports strict mode well, so default to True.
+ # Anthropic and others default to False for compatibility.
+ # This handles both legacy data without strict field and explicit None values.
+ if "strict" not in data or data.get("strict") is None:
+ model_endpoint_type = data.get("model_endpoint_type")
+ data["strict"] = model_endpoint_type == "openai"
+
+ return LLMConfig(**data)
# --------------------------