[Tech Debt] Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction
Summary
asyncio.iscoroutinefunction() is deprecated since Python 3.14 and is scheduled for removal in Python 3.16 (docs). The documented replacement is inspect.iscoroutinefunction(). On 3.14+ every call site below emits a DeprecationWarning; on 3.16 it would raise AttributeError.
crewAI targets Python 3.10-3.14, so this is currently warning noise rather than a breakage, but the fix is a mechanical, behavior-preserving swap: on 3.10+ both functions return identical results for async def functions, bound methods, functools.partial, and unittest.mock.AsyncMock (the 3.9 AsyncMock divergence does not apply since crewAI requires >= 3.10).
Affected call sites
| File | Line | Calls |
|---|---|---|
lib/crewai/src/crewai/flow/runtime/__init__.py |
2908, 2998 | 2 |
lib/crewai/src/crewai/rag/qdrant/utils.py |
84 | 1 |
lib/crewai/src/crewai/tools/base_tool.py |
115 | 1 |
lib/crewai-tools/src/crewai_tools/tools/stagehand_tool/stagehand_tool.py |
692 | 1 |
lib/crewai/tests/test_human_feedback_decorator.py |
286, 295 | 2 |
Suggested fix
Replace each asyncio.iscoroutinefunction(x) with inspect.iscoroutinefunction(x) (adding import inspect where missing), and update the two test assertions to use the same predicate the production code now uses.
I have the change ready and verified locally (pyflakes clean on all touched files, the swapped predicate behaves identically on 3.10-3.12 for the call shapes used here) and will open a PR referencing this issue.
Disclosure
This issue and the upcoming PR are AI-agent-assisted (generated with an AI coding agent). Please apply the llm-generated label per CONTRIBUTING - I cannot set labels without triage permission.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.