Skip to content

Conversation

@mshsheikh
Copy link
Contributor

In the refusal handling branch, the ResponseContentPartAddedEvent was incorrectly using ResponseOutputText as the part payload.
This violates the OpenAI Agents protocol, which requires refusal content to be represented by ResponseOutputRefusal so that downstream consumers can access the .refusal field.

This change updates the part field to use ResponseOutputRefusal(refusal="", type="refusal"), ensuring type consistency with both the accumulated state and the corresponding ResponseContentPartDoneEvent.

Additionally, the output_index calculation is slightly improved for clarity by explicitly using (1 if state.reasoning_content_index_and_output else 0) instead of a boolean expression, though the primary fix is the payload type correction.

In the refusal handling branch, the `ResponseContentPartAddedEvent` was incorrectly
using `ResponseOutputText` as the `part` payload. This violates the OpenAI Agents
protocol, which requires refusal content to be represented by `ResponseOutputRefusal`
so that downstream consumers can access the `.refusal` field.

This change updates the `part` field to use `ResponseOutputRefusal(refusal="", type="refusal")`,
ensuring type consistency with both the accumulated state and the corresponding
`ResponseContentPartDoneEvent`.

Additionally, the `output_index` calculation is slightly improved for clarity by
explicitly using `(1 if state.reasoning_content_index_and_output else 0)` instead of
a boolean expression, though the primary fix is the payload type correction.

This is a safe, minimal, and high-impact fix that aligns the stream handler with
the official response schema.
@seratch
Copy link
Member

seratch commented Oct 31, 2025

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@seratch seratch merged commit 0c4f2b9 into openai:main Oct 31, 2025
9 checks passed
@seratch seratch added this to the 0.5.x milestone Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants