Skip to content

Conversation

lorenzejay
Copy link
Collaborator

No description provided.

lucasgomide and others added 9 commits September 25, 2025 16:46
* feat: add app attributes to Agent

* feat: add actions attribute to Agent

* chore: resolve linter issues

* refactor: merge the apps and actions parameters into a single one

* fix: remove unnecessary print

* feat: logging error when CrewaiPlatformTools fails

* chore: export CrewaiPlatformTools directly from crewai_tools

* style: resolver linter issues

* test: fix broken tests

* style: solve linter issues

* fix: fix broken test
- Add crewai workspace member
- Fix vcr cassette paths and restore test dirs
- Resolve ci failures and update linter/pytest rules
* feat: add crewai-tools workspace structure

* Squashed 'temp-crewai-tools/' content from commit 9bae5633

git-subtree-dir: temp-crewai-tools
git-subtree-split: 9bae56339096cb70f03873e600192bd2cd207ac9

* feat: configure crewai-tools workspace package with dependencies

* fix: apply ruff auto-formatting to crewai-tools code

* chore: update lockfile

* fix: don't allow tool tests yet

* fix: comment out extra pytest flags for now

* fix: remove conflicting conftest.py from crewai-tools tests

* fix: resolve dependency conflicts and test issues

- Pin vcrpy to 7.0.0 to fix pytest-recording compatibility
- Comment out types-requests to resolve urllib3 conflict
- Update requests requirement in crewai-tools to >=2.32.0
* chore: update CI workflows and docs for monorepo structure

* fix: actions syntax
- Updated version to 1.0.0a1 in pyproject.toml for crewai and crewai-tools
- Adjusted version in __init__.py files for consistency
(cherry picked from commit d46e20fa09bcd2f5916282f5553ddeb7183bd92c)

if "docs" in url.netloc or ("docs" in url.path and url.scheme != "file"):
return DataType.DOCS_SITE
if "github.com" in url.netloc:

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
github.com
may be at an arbitrary position in the sanitized URL.

Copilot Autofix

AI 3 days ago

The best way to fix this problem is to avoid substring matching and instead safely check that the hostname is exactly github.com or matches a valid subdomain of github.com. This can be done by parsing the netloc into its hostname—using urlparse—and then checking with either an exact match, or, if allowing subdomains, ensuring the hostname is either github.com or ends with .github.com. This logic should only match valid hosts, not arbitrary hosts that merely contain the substring. The change should be made directly at line 146, replacing the substring check with an explicit, boundary-aware comparison using the parsed hostname.

No new method definitions are needed, but care should be taken to always use the correct element of urlparse (i.e., url.hostname, not url.netloc). The fix should, within the block beginning at line 139, replace the substring check with a secure check.


Suggested changeset 1
lib/crewai-tools/src/crewai_tools/rag/data_types.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/crewai-tools/src/crewai_tools/rag/data_types.py b/lib/crewai-tools/src/crewai_tools/rag/data_types.py
--- a/lib/crewai-tools/src/crewai_tools/rag/data_types.py
+++ b/lib/crewai-tools/src/crewai_tools/rag/data_types.py
@@ -143,7 +143,7 @@
 
             if "docs" in url.netloc or ("docs" in url.path and url.scheme != "file"):
                 return DataType.DOCS_SITE
-            if "github.com" in url.netloc:
+            if url.hostname == "github.com" or (url.hostname and url.hostname.endswith(".github.com")):
                 return DataType.GITHUB
 
             return DataType.WEBSITE
EOF
@@ -143,7 +143,7 @@

if "docs" in url.netloc or ("docs" in url.path and url.scheme != "file"):
return DataType.DOCS_SITE
if "github.com" in url.netloc:
if url.hostname == "github.com" or (url.hostname and url.hostname.endswith(".github.com")):
return DataType.GITHUB

return DataType.WEBSITE
Copilot is powered by AI and may make mistakes. Always verify output.
)

# Assertions
assert "https://example.com" in result

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

The string
https://example.com
may be at an arbitrary position in the sanitized URL.

Copilot Autofix

AI 3 days ago

To fix the problem, the test should not assert that the string "https://example.com" occurs somewhere in the result. Instead, it should parse any URLs from the string and verify the expected value, or—in this mocked context—assert the result equals the expected output string directly. The best fix for this case is to assert equality between result and the expected string "Successfully navigated to https://example.com", rather than that the substring appears somewhere in the result.

Edit the test function test_navigate_command in lib/crewai-tools/tests/tools/stagehand_tool_test.py, changing line 174 from a substring check to an equality check. No new imports are required.

Suggested changeset 1
lib/crewai-tools/tests/tools/stagehand_tool_test.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/crewai-tools/tests/tools/stagehand_tool_test.py b/lib/crewai-tools/tests/tools/stagehand_tool_test.py
--- a/lib/crewai-tools/tests/tools/stagehand_tool_test.py
+++ b/lib/crewai-tools/tests/tools/stagehand_tool_test.py
@@ -171,7 +171,7 @@
     )
 
     # Assertions
-    assert "https://example.com" in result
+    assert result == "Successfully navigated to https://example.com"
 
 
 @patch(
EOF
@@ -171,7 +171,7 @@
)

# Assertions
assert "https://example.com" in result
assert result == "Successfully navigated to https://example.com"


@patch(
Copilot is powered by AI and may make mistakes. Always verify output.
@tonykipkemboi tonykipkemboi marked this pull request as ready for review October 1, 2025 15:09
Copy link

cursor bot commented Oct 1, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on October 28.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@tonykipkemboi
Copy link
Member

@lorenzejay not sure if this is the right branch for me to have pushed the docs updates


result = brave_tool.run(search_query="test")
assert "Test Title" in result
assert "http://test.com" in result

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

The string
http://test.com
may be at an arbitrary position in the sanitized URL.

Copilot Autofix

AI 2 days ago

To fix this issue, we need to remove the substring check "http://test.com" in result on line 35 and instead assert that the expected URL is found in the output in a robust way. Since this is test code and we control the mocked response, the best fix is to parse the URL from the result using a regular expression (or similar precise extraction), and compare it for equality. Alternatively, if the result is JSON or a structured object, parse it properly and compare the URL directly. If the result is a formatted string (e.g., markdown or HTML), extract URLs from it and assert their presence exactly.

Specifically:

  • In test_brave_tool_search, replace the substring assertion with code that extracts URLs from the result and asserts that "http://test.com" is present as an exact-match URL, rather than as a substring.
  • Import re to enable safe URL extraction with a regular expression.
  • Adjust the code to parse and check URLs precisely.

Suggested changeset 1
lib/crewai-tools/tests/tools/brave_search_tool_test.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/crewai-tools/tests/tools/brave_search_tool_test.py b/lib/crewai-tools/tests/tools/brave_search_tool_test.py
--- a/lib/crewai-tools/tests/tools/brave_search_tool_test.py
+++ b/lib/crewai-tools/tests/tools/brave_search_tool_test.py
@@ -2,8 +2,8 @@
 
 from crewai_tools.tools.brave_search_tool.brave_search_tool import BraveSearchTool
 import pytest
+import re
 
-
 @pytest.fixture
 def brave_tool():
     return BraveSearchTool(n_results=2)
@@ -32,9 +31,10 @@
 
     result = brave_tool.run(search_query="test")
     assert "Test Title" in result
-    assert "http://test.com" in result
+    # Extract all URLs from the result and assert exact match
+    urls = re.findall(r'https?://[^\s\)"]+', result)
+    assert "http://test.com" in urls
 
-
 def test_brave_tool():
     tool = BraveSearchTool(
         n_results=2,
EOF
@@ -2,8 +2,8 @@

from crewai_tools.tools.brave_search_tool.brave_search_tool import BraveSearchTool
import pytest
import re


@pytest.fixture
def brave_tool():
return BraveSearchTool(n_results=2)
@@ -32,9 +31,10 @@

result = brave_tool.run(search_query="test")
assert "Test Title" in result
assert "http://test.com" in result
# Extract all URLs from the result and assert exact match
urls = re.findall(r'https?://[^\s\)"]+', result)
assert "http://test.com" in urls


def test_brave_tool():
tool = BraveSearchTool(
n_results=2,
Copilot is powered by AI and may make mistakes. Always verify output.
* ruff linted

* using native sdks with litellm fallback

* drop exa

* drop print on completion

* Refactor LLM and utility functions for type consistency

- Updated `max_tokens` parameter in `LLM` class to accept `float` in addition to `int`.
- Modified `create_llm` function to ensure consistent type hints and return types, now returning `LLM | BaseLLM | None`.
- Adjusted type hints for various parameters in `create_llm` and `_llm_via_environment_or_fallback` functions for improved clarity and type safety.
- Enhanced test cases to reflect changes in type handling and ensure proper instantiation of LLM instances.

* fix agent_tests

* fix litellm tests and usagemetrics fix

* drop print

* Refactor LLM event handling and improve test coverage

- Removed commented-out event emission for LLM call failures in `llm.py`.
- Added `from_agent` parameter to `CrewAgentExecutor` for better context in LLM responses.
- Enhanced test for LLM call failure to simulate OpenAI API failure and updated assertions for clarity.
- Updated agent and task ID assertions in tests to ensure they are consistently treated as strings.

* fix test_converter

* fixed tests/agents/test_agent.py

* Refactor LLM context length exception handling and improve provider integration

- Renamed `LLMContextLengthExceededException` to `LLMContextLengthExceededExceptionError` for clarity and consistency.
- Updated LLM class to pass the provider parameter correctly during initialization.
- Enhanced error handling in various LLM provider implementations to raise the new exception type.
- Adjusted tests to reflect the updated exception name and ensure proper error handling in context length scenarios.

* Enhance LLM context window handling across providers

- Introduced CONTEXT_WINDOW_USAGE_RATIO to adjust context window sizes dynamically for Anthropic, Azure, Gemini, and OpenAI LLMs.
- Added validation for context window sizes in Azure and Gemini providers to ensure they fall within acceptable limits.
- Updated context window size calculations to use the new ratio, improving consistency and adaptability across different models.
- Removed hardcoded context window sizes in favor of ratio-based calculations for better flexibility.

* fix test agent again

* fix test agent

* feat: add native LLM providers for Anthropic, Azure, and Gemini

- Introduced new completion implementations for Anthropic, Azure, and Gemini, integrating their respective SDKs.
- Added utility functions for tool validation and extraction to support function calling across LLM providers.
- Enhanced context window management and token usage extraction for each provider.
- Created a common utility module for shared functionality among LLM providers.

* chore: update dependencies and improve context management

- Removed direct dependency on `litellm` from the main dependencies and added it under extras for better modularity.
- Updated the `litellm` dependency specification to allow for greater flexibility in versioning.
- Refactored context length exception handling across various LLM providers to use a consistent error class.
- Enhanced platform-specific dependency markers for NVIDIA packages to ensure compatibility across different systems.

* refactor(tests): update LLM instantiation to include is_litellm flag in test cases

- Modified multiple test cases in test_llm.py to set the is_litellm parameter to True when instantiating the LLM class.
- This change ensures that the tests are aligned with the latest LLM configuration requirements and improves consistency across test scenarios.
- Adjusted relevant assertions and comments to reflect the updated LLM behavior.

* linter

* linted

* revert constants

* fix(tests): correct type hint in expected model description

- Updated the expected description in the test_generate_model_description_dict_field function to use 'Dict' instead of 'dict' for consistency with type hinting conventions.
- This change ensures that the test accurately reflects the expected output format for model descriptions.

* refactor(llm): enhance LLM instantiation and error handling

- Updated the LLM class to include validation for the model parameter, ensuring it is a non-empty string.
- Improved error handling by logging warnings when the native SDK fails, allowing for a fallback to LiteLLM.
- Adjusted the instantiation of LLM in test cases to consistently include the is_litellm flag, aligning with recent changes in LLM configuration.
- Modified relevant tests to reflect these updates, ensuring better coverage and accuracy in testing scenarios.

* fixed test

* refactor(llm): enhance token usage tracking and add copy methods

- Updated the LLM class to track token usage and log callbacks in streaming mode, improving monitoring capabilities.
- Introduced shallow and deep copy methods for the LLM instance, allowing for better management of LLM configurations and parameters.
- Adjusted test cases to instantiate LLM with the is_litellm flag, ensuring alignment with recent changes in LLM configuration.

* refactor(tests): reorganize imports and enhance error messages in test cases

- Cleaned up import statements in test_crew.py for better organization and readability.
- Enhanced error messages in test cases to use `re.escape` for improved regex matching, ensuring more robust error handling.
- Adjusted comments for clarity and consistency across test scenarios.
- Ensured that all necessary modules are imported correctly to avoid potential runtime issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants