You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(inference): handle null content and propagate reasoning from thinking models
Some providers return content=null for thinking models when the token
budget is consumed by reasoning. This caused a Pydantic ValidationError
in Message() because content must be str | list[ContentItem], not None.
Changes:
- Add optional `reasoning_content` field to Message for per-turn
reasoning. Named `reasoning_content` to match Qwen3's chat template
convention — templates that support this field render it natively
inside <think> tags
- RemoteInferenceEngine (Together, Fireworks, OpenAI, OpenRouter, Gemini,
GCP/Vertex, Cerebras, DeepSeek, Parasail, RemoteVLLM): default content
to empty string when null, extract reasoning from "reasoning" or
"reasoning_content" response fields
- AnthropicInferenceEngine: extract reasoning from "thinking" content
blocks, handle interleaved thinking/text blocks correctly
- BedrockInferenceEngine: same as Anthropic (thinking content blocks)
- SambanovaInferenceEngine: same as RemoteInferenceEngine (OpenAI-compat)
- conversation_utils: preserve reasoning_content when reconstructing
Messages in remove_excessive_images and truncate_text_in_content_items
- SGLang/local engines: no change (reasoning embedded in text via tags)
Null handling: uses explicit `is None` checks (not truthiness) so that
empty-string reasoning is preserved correctly.
Multiple content blocks (Anthropic/Bedrock) are concatenated directly
without separators, matching Anthropic's recommended approach.
Training: models whose chat templates reference `reasoning_content`
(e.g., Qwen3) will tokenize it natively. For models without template
support, a fallback to prepend reasoning as <think> tags in content
is needed (separate follow-up).
0 commit comments