Skip to content

Conversation

chenmoneygithub
Copy link
Collaborator

Responses API always return one choice instead of multiple choice. This is a very confusing behavior without clear documentation, but basically all items in the output in Response object map to one choice.

Copy link
Collaborator

@TomeHirata TomeHirata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

tool_calls = []
reasoning_contents = []

for output_item in response.output:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe add a comment that even though the output field of the responses API is a list, all output items belong to a single choice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

elif output_item_type == "function_call":
tool_calls.append(output_item.model_dump())
elif output_item_type == "reasoning":
if getattr(output_item, "content", None) and len(output_item.content) > 0:
Copy link
Collaborator

@TomeHirata TomeHirata Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: is it possible that output_item does not have content attribute when the item type is reasoning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically it's possible that either content or summary is unset, but again OpenAI is doing an odd job documenting Responses API.

if getattr(output_item, "content", None) and len(output_item.content) > 0:
for content_item in output_item.content:
reasoning_contents.append(content_item.text)
elif getattr(output_item, "summary", None) and len(output_item.summary) > 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@chenmoneygithub chenmoneygithub merged commit d6f4ebe into stanfordnlp:main Oct 1, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants