Files
crewAI/lib
Devin AI 1fc133acc3 Fix #4509: Strip markdown code-block fences from LLM JSON responses in Converter
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>
2026-02-18 13:18:51 +00:00
..