Skip to content

Commit 88a0373

Browse files
committed
feat: Add reasoning item handling to skip non-message content
1 parent 2f8ea0a commit 88a0373

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/agents/models/chatcmpl_converter.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ def maybe_response_output_message(cls, item: Any) -> ResponseOutputMessageParam
210210
return cast(ResponseOutputMessageParam, item)
211211
return None
212212

213+
@classmethod
214+
def maybe_item_reasoning(cls, item: Any) -> ItemReference | None:
215+
if isinstance(item, dict) and item.get("type") == "reasoning":
216+
return cast(ItemReference, item)
217+
return None
218+
213219
@classmethod
214220
def extract_text_content(
215221
cls, content: str | Iterable[ResponseInputContentParam]
@@ -453,13 +459,17 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
453459
}
454460
result.append(msg)
455461

456-
# 6) item reference => handle or raise
462+
# 6) Check reasoning content and don't append to result
463+
elif cls.maybe_item_reasoning(item):
464+
continue
465+
466+
# 7) item reference => handle or raise
457467
elif item_ref := cls.maybe_item_reference(item):
458468
raise UserError(
459469
f"Encountered an item_reference, which is not supported: {item_ref}"
460470
)
461471

462-
# 7) If we haven't recognized it => fail or ignore
472+
# 8) If we haven't recognized it => fail or ignore
463473
else:
464474
raise UserError(f"Unhandled item type or structure: {item}")
465475

0 commit comments

Comments
 (0)