Skip to content

fix(openai): preserve async streaming response parsing#607

Draft
Curtis Galione (cjgalione) wants to merge 2 commits into
mainfrom
codex/openai-agents-streaming-response
Draft

fix(openai): preserve async streaming response parsing#607
Curtis Galione (cjgalione) wants to merge 2 commits into
mainfrom
codex/openai-agents-streaming-response

Conversation

@cjgalione

Copy link
Copy Markdown
Contributor

Summary

  • await asynchronous raw-response parsing before wrapping Responses API streams
  • preserve the awaitable parse() contract expected by OpenAI Agents
  • add a regression test that awaits and consumes the parsed async stream

Root cause

openai.AsyncAPIResponse.parse() is asynchronous. The tracing wrapper replaced it with a synchronous method while wrapping the un-awaited coroutine, so OpenAI Agents' streaming path could fail when it entered with_streaming_response and awaited api_response.parse().

The wrapper now records whether the underlying response parses asynchronously, awaits that parse before constructing the traced stream, and exposes an awaitable parse() on the returned raw-response proxy. Synchronous raw-response behavior remains unchanged.

Validation

  • full OpenAI integration suites with OpenAI 2.46.0, 1.92.0, 1.77.0, and 1.71.0
  • full OpenAI Agents suites with Agents 0.18.3, 0.13.6, and 0.0.19
  • actual Agents 0.18.3 / OpenAI 2.31.0 streaming _fetch_response contract exercised against a mock SSE response
  • all pre-commit hooks: Ruff format/check, cassette consistency, pytest-pin synchronization, and codespell
  • Pylint error checks on both changed files
  • final diff and customer-identifier audit

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.

1 participant