Skip to content

fix(streaming): accumulate response.refusal.delta in Responses stream state#3387

Open
yen0304 wants to merge 1 commit into
openai:mainfrom
yen0304:fix-responses-refusal-delta-accumulation
Open

fix(streaming): accumulate response.refusal.delta in Responses stream state#3387
yen0304 wants to merge 1 commit into
openai:mainfrom
yen0304:fix-responses-refusal-delta-accumulation

Conversation

@yen0304

@yen0304 yen0304 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • ResponseStreamState.accumulate_event handles response.output_text.delta and response.function_call_arguments.delta, but had no case for response.refusal.delta.
  • As a result, when a model refuses a request mid-stream, the refusal text is never accumulated into the snapshot — the in-progress snapshot's refusal content stays empty even though delta events are being emitted.
  • The sibling Chat Completions streaming (chat/_completions.py) accumulates refusal deltas; this brings the Responses stream state in line.

Test

  • Adds a unit test that drives the accumulator with a sequence of response.refusal.delta events and asserts the snapshot's refusal content is concatenated.

… state

ResponseStreamState.accumulate_event handled response.output_text.delta
and response.function_call_arguments.delta but not response.refusal.delta.
When a model refused a request mid-stream, the refusal text was never
accumulated into the snapshot, so the snapshot's refusal content stayed
empty while the stream was in progress.

The sibling Chat Completions streaming accumulates refusal deltas; this
brings the Responses stream state in line. Adds a unit test that drives
the accumulator with a sequence of refusal deltas.
@yen0304 yen0304 requested a review from a team as a code owner June 9, 2026 02:44
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