Skip to content

fix(llm): forward thinking param to LiteLLM completion for all providers#5720

Open
Beandon13 wants to merge 1 commit intocrewAIInc:mainfrom
Beandon13:fix/crewai-5537-thinking-param-openrouter
Open

fix(llm): forward thinking param to LiteLLM completion for all providers#5720
Beandon13 wants to merge 1 commit intocrewAIInc:mainfrom
Beandon13:fix/crewai-5537-thinking-param-openrouter

Conversation

@Beandon13
Copy link
Copy Markdown

Summary

  • The thinking field was defined on LLM (line 346) but never included in _prepare_completion_params, so it was silently dropped for every provider that uses LiteLLM directly (OpenRouter, DeepSeek, Ollama, etc.)
  • Only the native AnthropicCompletion code path correctly forwarded thinking; users of openrouter/anthropic/claude-* or any other provider got nothing
  • Add "thinking": self.thinking alongside "reasoning_effort": self.reasoning_effort so the param reaches LiteLLM for all providers

Closes #5537

Testing

pytest lib/crewai/tests/test_llm.py::test_thinking_param_included_in_completion_params -v
PASSED lib/crewai/tests/test_llm.py::test_thinking_param_included_in_completion_params

…iders

The `thinking` field was declared on the `LLM` model but never added to
the `params` dict in `_prepare_completion_params`, causing it to be
silently dropped for OpenRouter, DeepSeek, Ollama, and every other
provider that goes through LiteLLM directly. Only the native
AnthropicCompletion path included `thinking`.

Add `"thinking": self.thinking` alongside `reasoning_effort` in
`_prepare_completion_params` so that LLM(model="openrouter/anthropic/…",
thinking={...}) propagates the extended-thinking config correctly.

Closes crewAIInc#5537

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

[BUG] Problems with OpenRouter thinking models

1 participant