Skip to content

fix(sandbox): preserve UTF-8 boundaries in Cloudflare SSE - #4707

Merged
seratch merged 3 commits into
openai:mainfrom
Hughhhhcoder:codex/openai-agents-sse-utf8
Aug 27, 2026
Merged

seratch merged 3 commits into
openai:mainfrom
Hughhhhcoder:codex/openai-agents-sse-utf8

Conversation

@Hughhhhcoder

@Hughhhhcoder Hughhhhcoder commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cloudflare sandbox execution decoded each aiohttp byte chunk as UTF-8 before passing it to the SSE line decoder. A multi-byte UTF-8 code point split across network chunks therefore raised UnicodeDecodeError instead of being decoded after the bytes were reassembled.

The network stream boundary was incorrectly treated as a text boundary even though UTF-8 character boundaries are independent of aiohttp byte-chunk boundaries. This change lets _SSELineDecoder accept byte chunks and decode only complete SSE lines with its incremental decoder, passes raw aiohttp chunks into the decoder, and adds deterministic regression coverage for split UTF-8 code points.

No public API signatures change. SSE framing, CR/LF handling, event dispatch, and error propagation remain unchanged for complete text and byte chunks.

Test plan

  • pytest -q tests/extensions/sandbox/test_cloudflare.py -k 'utf8_split or sse_line_decoder' — 12 passed, 84 deselected.
  • ruff check src/agents/extensions/sandbox/cloudflare/sandbox.py tests/extensions/sandbox/test_cloudflare.py — passed.
  • ruff format --check src/agents/extensions/sandbox/cloudflare/sandbox.py tests/extensions/sandbox/test_cloudflare.py — passed.
  • pyright src/agents/extensions/sandbox/cloudflare/sandbox.py — 0 errors, 0 warnings.
  • /usr/bin/env -u OPENAI_API_KEY OPENAI_AGENTS_TEST_IN_CODEX_SANDBOX=1 UV_DEFAULT_INDEX=https://pypi.org/simple bash .agents/skills/code-change-verification/scripts/run.sh — passed (make format, make lint, make typecheck, and make tests).
  • Current-head Codex code and security reviews found no issues.

Issue number

N/A — independently reproduced bug with no pre-existing issue.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run a current-head review before marking this PR ready for maintainer review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54f9430aaf

ℹ️ 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".

Comment thread pyproject.toml Resolved
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

All prior review feedback has been addressed in the current head (b6ccf77). @codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: b6ccf77bbb

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: b6ccf77bbb

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@seratch seratch added this to the 0.22.x milestone Aug 27, 2026
@seratch
seratch merged commit 374b54d into openai:main Aug 27, 2026
18 checks passed
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