Skip to content

fix(streaming): reconcile completed Responses output items - #3615

Open
by-openai wants to merge 1 commit into
mainfrom
agent/fix-response-output-item-done-snapshots
Open

fix(streaming): reconcile completed Responses output items#3615
by-openai wants to merge 1 commit into
mainfrom
agent/fix-response-output-item-done-snapshots

Conversation

@by-openai

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Update ResponseStreamState to replace provisional output items from response.output_item.added with the authoritative item received in response.output_item.done.

A reasoning item's initial encrypted_content, summary, and status can differ from its completed values. Ignoring the done event leaves the streaming snapshot with incomplete encrypted reasoning that cannot safely be replayed. Completed assistant messages and function calls likewise retain stale content, arguments, and status.

The reconciliation preserves ParsedResponseOutputMessage and ParsedResponseFunctionToolCall wrappers and applies to both synchronous and asynchronous Responses streams through their shared state.

Regression tests cover:

  • Reasoning items whose preliminary ciphertext differs from the completed ciphertext.
  • Completed assistant message content, status, and phase.
  • Completed function-call arguments and status.

Validation:

  • pytest tests/lib — 259 passed.
  • ruff check and ruff format --check on both changed files.
  • pyright on both changed files.
  • mypy on the changed streaming implementation.

Additional context & links

@by-openai
by-openai marked this pull request as ready for review August 14, 2026 03:39
@by-openai
by-openai requested a review from a team as a code owner August 14, 2026 03:39
@by-openai
by-openai requested review from apcha-oai and a lite review from Copilot and removed request for Copilot August 14, 2026 03:39
@openai-sdks

openai-sdks Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.408s for Python SDK PR #3615.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 213ms
tests/chat-completions-create.test.ts ✅ Passed 209ms
tests/chat-completions-stream.test.ts ✅ Passed 145ms
tests/files-content-binary.test.ts ✅ Passed 234ms
tests/files-create-multipart.test.ts ✅ Passed 209ms
tests/files-list-pagination.test.ts ✅ Passed 146ms
tests/initialize-config.test.ts ✅ Passed 202ms
tests/instance-isolation.test.ts ✅ Passed 239ms
tests/models-list.test.ts ✅ Passed 225ms
tests/responses-background-lifecycle.test.ts ✅ Passed 213ms
tests/responses-body-method-errors.test.ts ✅ Passed 329ms
tests/responses-cancel-timeout.test.ts ✅ Passed 204ms
tests/responses-cancel.test.ts ✅ Passed 226ms
tests/responses-compact-retries.test.ts ✅ Passed 366ms
tests/responses-compact.test.ts ✅ Passed 289ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 328ms
tests/responses-create-advanced.test.ts ✅ Passed 274ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.182s
tests/responses-create-errors.test.ts ✅ Passed 193ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 254ms
tests/responses-create-retries.test.ts ✅ Passed 262ms
tests/responses-create-stream-failures.test.ts ✅ Passed 137ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 209ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.723s
tests/responses-create-stream.test.ts ✅ Passed 104ms
tests/responses-create-terminal-states.test.ts ✅ Passed 251ms
tests/responses-create-timeout.test.ts ✅ Passed 271ms
tests/responses-create.test.ts ✅ Passed 312ms
tests/responses-delete.test.ts ✅ Passed 214ms
tests/responses-input-items-errors.test.ts ✅ Passed 440ms
tests/responses-input-items-list.test.ts ✅ Passed 315ms
tests/responses-input-items-options.test.ts ✅ Passed 303ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 251ms
tests/responses-input-tokens-count.test.ts ✅ Passed 181ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.854s
tests/responses-not-found-errors.test.ts ✅ Passed 261ms
tests/responses-parse.test.ts ✅ Passed 509ms
tests/responses-retrieve-retries.test.ts ✅ Passed 242ms
tests/responses-retrieve.test.ts ✅ Passed 239ms
tests/responses-stored-method-errors.test.ts ✅ Passed 617ms
tests/retry-behavior.test.ts ✅ Passed 3.17s
tests/sdk-error-shape.test.ts ✅ Passed 271ms

View OkTest run #31767474355

SDK merge (6404589e77db) · head (9dad2ad84f53) · base (d9029e3ada3c) · OkTest (a845fa206fa4)

@ting-hong-shieh ting-hong-shieh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Validated at 9dad2ad8 against base d9029e3a.

I ran the same synthetic response.createdresponse.output_item.addedresponse.output_item.done sequence for reasoning, message, and function-call items. The canonical snapshot hashes changed as follows:

Item Base snapshot Done item / head snapshot
Reasoning aa8c8dd24e79 b897c980880a
Message 6a64d2e6f63e 1c0e1e631e2a
Function call 68c4bd453415 b0fc42c0be19

On the base, all three snapshots still held their provisional values after the done event. On this head, each snapshot matched the authoritative done item exactly. The completed message remained a ParsedResponseOutputMessage with ParsedResponseOutputText content, and the function call remained a ParsedResponseFunctionToolCall.

Validation on the exact head:

  • pytest -q -n 0 tests/lib — 259 passed
  • focused Responses file — 10 passed
  • Ruff lint and format checks — passed
  • Pyright — 0 errors; Mypy — passed
  • compilation and git diff --check — passed

The three public workflow runs are also green. The snapshot used constructed local events only; it made no API request and used no credentials.

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