fix(pixel-teams): stream UTF-8 chunks incrementally without splitting multi-byte sequences - #5698
Open
vaibhavsrv wants to merge 1 commit into
Open
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
… multi-byte sequences
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
In
ods/extensions/services/dashboard-api/routers/pixel_teams.py, the_run(owner, agent)task consumes SSE events from_retained_chat_stream(...)viaasync for chunk in response.body_iterator:. For incoming byte chunks, it directly executedbuffered += chunk.decode("utf-8") if isinstance(chunk, bytes) else chunk.If a multi-byte UTF-8 character (such as emoji, symbols, or localized characters) is split across network TCP or chunk boundaries by the upstream inference stream, calling
chunk.decode("utf-8")on the first chunk containing an incomplete sequence raises an unhandledUnicodeDecodeError('utf-8' codec can't decode bytes in position ...: unexpected end of data). This abruptly crashes the agent team worker task and marks the worker as failed.This surgical fix introduces
codecs.getincrementaldecoder("utf-8")()to buffer incomplete multi-byte code units across chunk boundaries before appending decoded text to the SSE line buffer.Validation
b'\xf0\x9f'in chunk 1 followed byb'\x9a\x80'in chunk 2) on unpatchedpixel_teams.py; baseline immediately failed withUnicodeDecodeError._rundecodes the full character (🚀) without errors and emits the delta choice event.pixel-teams suites: 29 passed. New-test syntax and diff checks pass; new regressions wired into test suite.Overlap check
fix(pixel-settings): convert decode and protocol failures to unsafe-settings-source): Hardens coordinator file decoding; zero overlap with SSE streaming inpixel_teams.py.fix(pixel-settings): reject active token limits exceeding provider capacity): Bounds runtime capability values incontract.py; zero overlap with agent team streams.fix(dashboard-api): tolerate evicted or missing attempts during pixel chat cancel): Touches dashboard API chat result store lifecycle; zero overlap with agent team SSE decoding.fix(pixel-teams): safely ignore non-conforming or corrupted team history files): Touched team history JSON loading; this PR addresses HTTP chunk streaming without conflicts.Risk / AI disclosure
AI-assisted investigation, implementation and CLI regressions. This uses Python's standard incremental UTF-8 decoder during SSE chunk buffering and does not alter downstream SSE event parsing or contract schemas. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.
Follow-up integration evidence
Composed with #5697 at
8b9f0e2e3without conflicts. Production and test diffs passed together; team coordinator and streaming checks remain intact.Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.