fix: add Python 3.14 compatibility (asyncio.get_running_loop)#5110
Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Open
fix: add Python 3.14 compatibility (asyncio.get_running_loop)#5110devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
…p() with get_running_loop() Python 3.14 changed asyncio.get_event_loop() to raise RuntimeError when no running event loop exists instead of silently creating one. This broke all async code paths that relied on get_event_loop(). Changes: - Replace asyncio.get_event_loop() with asyncio.get_running_loop() in all async contexts across crewai core and crewai-tools - Update requires-python from '<3.14' to '<3.15' in all pyproject.toml files - Add comprehensive tests for Python 3.14 async compatibility - Regenerate uv.lock for the updated version constraint Closes #5109 Co-Authored-By: João <joao@crewai.com>
Contributor
Author
|
Prompt hidden (unlisted session) |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: João <joao@crewai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Python 3.14 changed
asyncio.get_event_loop()to raiseRuntimeErrorwhen no running event loop exists, instead of silently creating one (completing a deprecation cycle started in 3.10). This PR:asyncio.get_event_loop()calls withasyncio.get_running_loop()across 8 files in bothcrewaicore andcrewai-tools. All call sites were already insideasyncfunctions, soget_running_loop()is the correct replacement.requires-pythonfrom<3.14to<3.15in all 4pyproject.tomlfiles.CrewStructuredTool.ainvoke,create_streaming_state, andChromaDBClient._alocked.uv.lockfor the updated Python version constraint.Closes #5109
Review & Testing Checklist for Human
browser_toolkit.pypatched_run(line 97): This is a sync wrapper that callsget_running_loop()thenloop.run_until_complete(). The oldget_event_loop()would create a loop when called from a non-async context;get_running_loop()will raiseRuntimeErrorinstead. Theexcept Exceptionblock catches this, but verify that the fallback behavior is acceptable for all callers ofpatched_run.browser_toolkit.py_nest_current_loop(line 542): Theif loop.is_running()guard was removed. This is logically safe sinceget_running_loop()only succeeds when a loop is running, but confirm no subtle difference exists.uv.lockdiff: Lock file was fully regenerated. Skim for unexpected dependency version bumps unrelated to this change.Recommended test plan: Run the full test suite on Python 3.13 to confirm no regressions. If a Python 3.14 alpha/beta is available in CI, run tests there as well to validate the fix end-to-end.
Notes
async deffunctions, makingget_running_loop()a safe 1:1 replacement.ast.Num,ast.Str, etc.) was found in the codebase.browser_toolkit.pyto pass theruff format --checkCI gate.Link to Devin session: https://app.devin.ai/sessions/97cbdc58d7bc441d9f59eda15351fadd