From 1dc310844c2bc5b7317313e380add5d4c2f86fe7 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Sun, 12 Apr 2026 05:08:32 +0800 Subject: [PATCH] refactor: route Gemini async paths through _get_async_client `_ahandle_completion` and `_ahandle_streaming_completion` were calling `_get_sync_client()` directly. The other native providers (OpenAI, Anthropic, Azure) consistently route async code through `_get_async_client()`; matching that abstraction here keeps the contract consistent and lets a future async-specific override work without re-touching call sites. --- lib/crewai/src/crewai/llms/providers/gemini/completion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/crewai/src/crewai/llms/providers/gemini/completion.py b/lib/crewai/src/crewai/llms/providers/gemini/completion.py index 1607b6395..1b2fb26cb 100644 --- a/lib/crewai/src/crewai/llms/providers/gemini/completion.py +++ b/lib/crewai/src/crewai/llms/providers/gemini/completion.py @@ -1216,7 +1216,7 @@ class GeminiCompletion(BaseLLM): try: # The API accepts list[Content] but mypy is overly strict about variance contents_for_api: Any = contents - response = await self._get_sync_client().aio.models.generate_content( + response = await self._get_async_client().aio.models.generate_content( model=self.model, contents=contents_for_api, config=config, @@ -1257,7 +1257,7 @@ class GeminiCompletion(BaseLLM): # The API accepts list[Content] but mypy is overly strict about variance contents_for_api: Any = contents - stream = await self._get_sync_client().aio.models.generate_content_stream( + stream = await self._get_async_client().aio.models.generate_content_stream( model=self.model, contents=contents_for_api, config=config,