Skip to content

Fix LiteLLM reasoning_content handling#741

Open
cnYui wants to merge 2 commits into
thinking-machines-lab:mainfrom
cnYui:fix-litellm-reasoning-content
Open

Fix LiteLLM reasoning_content handling#741
cnYui wants to merge 2 commits into
thinking-machines-lab:mainfrom
cnYui:fix-litellm-reasoning-content

Conversation

@cnYui
Copy link
Copy Markdown

@cnYui cnYui commented May 28, 2026

Summary

  • Split structured ThinkingPart content into message.reasoning_content for the LiteLLM provider.
  • Keep user-visible TextPart output in message.content without embedding <think>...</think> blocks.
  • Preserve reasoning_content when building LiteLLM ModelResponse objects.

Context

The provider previously formatted structured assistant content with format_content_as_string(). For outputs containing ThinkingPart, that produced content like <think>reasoning</think>\nanswer, which made reasoning text appear in message.content and left LiteLLM callers without a clean reasoning_content field.

This is related to #684, but this PR is scoped to the cookbook LiteLLM custom provider rather than the hosted OpenAI-compatible API.

Test Plan

  • uv run pytest tinker_cookbook/third_party/litellm/provider_test.py -q
  • uv run ruff check tinker_cookbook/third_party/litellm/
  • uv run pyright tinker_cookbook/third_party/litellm
  • git diff --check HEAD~1..HEAD

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.

1 participant