-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Feature Area
Core functionality
Is your feature request related to a an existing bug? Please link it here.
N/A
Describe the solution you'd like
Enable CrewAI agents to use Claude's extended thinking feature seamlessly with tool use. Currently, when thinking is enabled on an agent's LLM, subsequent tool-result messages fail because CrewAI's message handling doesn't preserve thinking blocks as required by the Anthropic API.
Desired behavior:
- When an agent receives a response with thinking blocks
enabled, extract and preserve those thinking blocks - When sending tool results back to the LLM in follow-up
messages, re-include the thinking blocks from the previous
assistant message - Maintain thinking block continuity across the entire
tool-use loop until the agent reaches a final answer - Ensure the thinking parameter is managed consistently -
if thinking is enabled for an agent, all messages in a
conversation turn should include thinking blocks
Expected workflow:
Turn 1: User message → Agent LLM call with thinking=enabled
Response: [thinking block] + [tool_use block]
↓
Turn 2: Include thinking block from Turn 1 + tool result →
Agent LLM call with thinking=enabled
Response: [text block] (final answer)
Implementation should follow Anthropic's specification:
According to https://docs.anthropic.com/claude/docs/build-wi
th-claude/extended-thinking, when using extended thinking
with tool use:
- Tool use loops are part of a single assistant turn
- Thinking blocks must be preserved and passed back to the
API - The complete unmodified thinking block must be included in
follow-up messages to maintain reasoning continuity
This would enable:
- Agents to use Claude's extended thinking with any tools
- Deeper reasoning during tool selection and result
processing - Better quality outputs for complex code generation
tasks - Full compatibility with Anthropic's native thinking
capabilities
Describe alternatives you've considered
No response
Additional context
Willingness to Contribute
Yes, I'd be happy to submit a pull request