fix(openai): handle content blocks without type key in responses api conversion (#36725)

This commit is contained in:
William FH
2026-04-14 12:13:40 -07:00
committed by GitHub
parent 01a324af0e
commit 885f2c2c2d
4 changed files with 54 additions and 6 deletions

View File

@@ -335,10 +335,9 @@ def _convert_from_v03_ai_message(message: AIMessage) -> AIMessage:
# Reasoning
if reasoning := message.additional_kwargs.get("reasoning"):
if isinstance(message, AIMessageChunk) and message.chunk_position != "last":
buckets["reasoning"].append({**reasoning, "type": "reasoning"})
else:
buckets["reasoning"].append(reasoning)
if "type" not in reasoning:
reasoning = {**reasoning, "type": "reasoning"}
buckets["reasoning"].append(reasoning)
# Refusal
if refusal := message.additional_kwargs.get("refusal"):