mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-10 13:02:37 +00:00
When LLMs return JSON wrapped in markdown code blocks (e.g. ```json...```), the Converter.to_pydantic() method failed to parse the response, causing Pydantic validation errors when saving to long-term memory. Changes: - Add _strip_markdown_fences() helper to remove markdown code-block delimiters - Apply fence stripping before model_validate_json() in both function-calling and non-function-calling paths of Converter.to_pydantic() - Add handle_partial_json() fallback in the function-calling path - Apply fence stripping in convert_to_model() before json.loads() - Add 11 tests covering the fix Co-Authored-By: João <joao@crewai.com>