Commit d9cdf40
authored
fix: use ResponseOutputRefusal for refusal content part added event
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.1 parent f91b38f commit d9cdf40
1 file changed
+4
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
318 | 316 | | |
319 | 317 | | |
320 | 318 | | |
| |||
0 commit comments