From ea36633cd559fc6b0b1eb955937aafd45e7e2264 Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Tue, 13 Jan 2026 17:21:26 -0800 Subject: [PATCH] fix: make sure structured outputs turned on for openai (#8669) --- letta/helpers/converters.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/letta/helpers/converters.py b/letta/helpers/converters.py index 424dad81..24cc2ab1 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) # --------------------------