Fix issue #2383: Add invoke method to BaseTool for models without function calling support #2384
+216
−1
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.
Fix issue #2383: Add invoke method to BaseTool for models without function calling support
This PR fixes issue #2383 where custom tools' _run method is not being called when using models like QwQ-32B-Preview and deepseek-chat that don't support function calling.
Problem
Some models (specifically QwQ-32B-Preview and deepseek-chat) don't support function calling, and the tool execution mechanism in CrewAI relies on the
invoke()
method which is only implemented inCrewStructuredTool
but not inBaseTool
.Solution
The fix adds an
invoke()
method toBaseTool
that:_run
method with the appropriate argumentsThis ensures that tools can be executed even when using models that don't support function calling.
Security Enhancements
Based on code review feedback, the implementation includes several security features:
Testing
Added comprehensive tests to verify the fix works correctly with:
Link to Devin run: https://app.devin.ai/sessions/32a7fbb5786649ca817046f78ec4b9f1
Requested by: User