This commit is contained in:
Chester Curme 2025-07-10 18:18:53 -04:00
parent 8da2bec1c3
commit 72bb858eec
2 changed files with 5 additions and 4 deletions

View File

@ -485,12 +485,13 @@ def _implode_reasoning_blocks(blocks: list[dict[str, Any]]) -> Iterable[dict[str
while i < n: while i < n:
block = blocks[i] block = blocks[i]
# Ordinary block just yield a shallow copy # Skip non-reasoning blocks or blocks already in Responses format
if block.get("type") != "reasoning": if block.get("type") != "reasoning" or "summary" in block:
yield dict(block) yield dict(block)
i += 1 i += 1
continue continue
elif "reasoning" not in block: elif "reasoning" not in block and "summary" not in block:
# {"type": "reasoning", "id": "rs_..."}
yield {**block, "summary": []} yield {**block, "summary": []}
i += 1 i += 1
continue continue

View File

@ -2563,7 +2563,7 @@ def test_convert_to_v1_from_chat_completions(
), ),
AIMessage( AIMessage(
[ [
{"type": "reasoning", "id": "abc123"}, {"type": "reasoning", "id": "abc123", "summary": []},
{ {
"type": "reasoning", "type": "reasoning",
"id": "abc234", "id": "abc234",