diff --git a/backend/open_webui/utils/anthropic.py b/backend/open_webui/utils/anthropic.py index b6672af48f..36237bdaeb 100644 --- a/backend/open_webui/utils/anthropic.py +++ b/backend/open_webui/utils/anthropic.py @@ -202,7 +202,9 @@ def convert_anthropic_to_openai_payload( ) ) elif block_type in ('thinking', 'redacted_thinking'): - openai_content.append(_copy_cache_control(block, dict(block))) + # Unsigned thinking cannot be replayed upstream + if block_type == 'redacted_thinking' or block.get('signature'): + openai_content.append(_copy_cache_control(block, dict(block))) elif block_type == 'image': source = block.get('source', {}) if source.get('type') == 'base64': @@ -369,7 +371,7 @@ def convert_anthropic_to_openai_payload( msg_dict['content'] = '' msg_dict['tool_calls'] = tool_calls messages.append(msg_dict) - elif openai_content: + elif openai_content or role == 'assistant': messages.append({'role': role, 'content': _finalize_openai_content(openai_content)}) else: messages.append({'role': role, 'content': str(content) if content else ''})