feat: Add extended thinking support for Anthropic Claude #3965
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.
feat: Add extended thinking support for Anthropic Claude
Summary
Implements support for Anthropic's extended thinking feature (as described in Anthropic's documentation) to enable CrewAI agents to use Claude's deeper reasoning capabilities with tool use.
Changes:
thinkingparameter toAnthropicCompletion.__init__()to accept extended thinking configuration (e.g.,{"type": "enabled", "budget_tokens": 5000})_prepare_completion_params()to include the thinking parameter in API calls when configured_handle_tool_use_conversation()already preserves thinking blocks correctly by usinginitial_response.contentdirectly (line 576)Fixes: #3964
Review & Testing Checklist for Human
thinking={"type": "enabled", "budget_tokens": 5000}and verify that:dict[str, Any]type is acceptable or if we need stricter typing (e.g., TypedDict for{"type": "enabled", "budget_tokens": int})Test Plan
Expected: The agent should use extended thinking, call the calculator tool, and return the correct answer (42).
Notes
_handle_tool_use_conversation()method already preserves thinking blocks by usinginitial_response.contentdirectly, so no changes were needed there