From 21ebc01e9d170e07dbaf3d31f0f4308d3c2c38cf Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 10:16:32 +0000 Subject: [PATCH] fix: relax openai dependency constraint to allow OpenLit integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The openai dependency was constrained to ~=1.83.0 which only allows versions >=1.83.0,<1.84.0. This prevented integration with OpenLit which requires openai >= 1.92.0. Changed the constraint to >=1.83.0,<2 to: - Allow OpenLit and other integrations that need newer openai versions - Prevent potential breaking changes from openai 2.x Added tests to verify the constraint allows OpenLit-compatible versions while maintaining an upper bound for stability. Fixes #4270 Co-Authored-By: João --- lib/crewai/pyproject.toml | 2 +- .../tests/test_dependency_constraints.py | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 lib/crewai/tests/test_dependency_constraints.py diff --git a/lib/crewai/pyproject.toml b/lib/crewai/pyproject.toml index ada287cd8..6e9a1f2a1 100644 --- a/lib/crewai/pyproject.toml +++ b/lib/crewai/pyproject.toml @@ -10,7 +10,7 @@ requires-python = ">=3.10, <3.14" dependencies = [ # Core Dependencies "pydantic~=2.11.9", - "openai~=1.83.0", + "openai>=1.83.0,<2", "instructor>=1.3.3", # Text Processing "pdfplumber~=0.11.4", diff --git a/lib/crewai/tests/test_dependency_constraints.py b/lib/crewai/tests/test_dependency_constraints.py new file mode 100644 index 000000000..e0f59c444 --- /dev/null +++ b/lib/crewai/tests/test_dependency_constraints.py @@ -0,0 +1,91 @@ +"""Test that dependency constraints are compatible with common integrations.""" + +import tomllib +from pathlib import Path + +from packaging.specifiers import SpecifierSet +from packaging.version import Version + + +def get_pyproject_dependencies() -> dict[str, str]: + """Parse pyproject.toml and return dependencies as a dict.""" + pyproject_path = Path(__file__).parent.parent / "pyproject.toml" + with open(pyproject_path, "rb") as f: + data = tomllib.load(f) + + dependencies = {} + for dep in data.get("project", {}).get("dependencies", []): + if ">=" in dep or "~=" in dep or "==" in dep or "<" in dep: + parts = dep.replace(">=", " ").replace("~=", " ").replace("==", " ").replace(",", " ").replace("<", " <").split() + if parts: + name = parts[0].strip() + constraint = dep[len(name):].strip() + dependencies[name] = constraint + return dependencies + + +def test_openai_constraint_allows_openlit_compatible_versions(): + """Test that openai constraint allows versions >= 1.92.0 required by OpenLit. + + This test ensures that the openai dependency constraint is relaxed enough + to allow integration with OpenLit, which requires openai >= 1.92.0. + + See: https://github.com/crewAIInc/crewAI/issues/4270 + """ + dependencies = get_pyproject_dependencies() + + assert "openai" in dependencies, "openai should be in dependencies" + + openai_constraint = dependencies["openai"] + specifier = SpecifierSet(openai_constraint) + + openlit_required_version = Version("1.92.0") + assert openlit_required_version in specifier, ( + f"openai constraint '{openai_constraint}' should allow version 1.92.0 " + f"required by OpenLit. Current constraint blocks OpenLit integration." + ) + + higher_1x_version = Version("1.109.0") + assert higher_1x_version in specifier, ( + f"openai constraint '{openai_constraint}' should allow higher 1.x versions" + ) + + +def test_openai_constraint_has_upper_bound(): + """Test that openai constraint has an upper bound to prevent breaking changes. + + The constraint should prevent openai 2.x which may have breaking changes. + """ + dependencies = get_pyproject_dependencies() + + assert "openai" in dependencies, "openai should be in dependencies" + + openai_constraint = dependencies["openai"] + specifier = SpecifierSet(openai_constraint) + + version_2 = Version("2.0.0") + assert version_2 not in specifier, ( + f"openai constraint '{openai_constraint}' should NOT allow version 2.0.0 " + f"to prevent potential breaking changes from major version bump" + ) + + +def test_openai_constraint_minimum_version(): + """Test that openai constraint has a reasonable minimum version.""" + dependencies = get_pyproject_dependencies() + + assert "openai" in dependencies, "openai should be in dependencies" + + openai_constraint = dependencies["openai"] + specifier = SpecifierSet(openai_constraint) + + min_version = Version("1.83.0") + assert min_version in specifier, ( + f"openai constraint '{openai_constraint}' should allow version 1.83.0" + ) + + old_version = Version("1.82.0") + assert old_version not in specifier, ( + f"openai constraint '{openai_constraint}' should NOT allow version 1.82.0 " + f"which is below the minimum required version" + )