From 415b89440536c1f49ab358f52adc7be0a1009add Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 12:54:20 +0000 Subject: [PATCH] fix: wrap sync instructor.to_json() in asyncio.to_thread for ato_json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses Cursor Bugbot feedback: the function-calling path in ato_json was still calling _create_instructor().to_json() synchronously, blocking the event loop. Now wrapped in asyncio.to_thread() to offload the blocking call to a separate thread. Co-Authored-By: João --- lib/crewai/src/crewai/utilities/converter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/crewai/src/crewai/utilities/converter.py b/lib/crewai/src/crewai/utilities/converter.py index d253cc6e6..825c70792 100644 --- a/lib/crewai/src/crewai/utilities/converter.py +++ b/lib/crewai/src/crewai/utilities/converter.py @@ -1,5 +1,6 @@ from __future__ import annotations +import asyncio import json import re from typing import TYPE_CHECKING, Any, Final, TypedDict @@ -225,7 +226,7 @@ class Converter(OutputConverter): """ try: if self.llm.supports_function_calling(): - return self._create_instructor().to_json() + return await asyncio.to_thread(self._create_instructor().to_json) return json.dumps( await self.llm.acall( [