Skip to content

Fix streaming top-level objects without list wrapping#1541

Open
selamw1 wants to merge 2 commits into
a2ui-project:mainfrom
selamw1:stream-parser-top-level-objects
Open

Fix streaming top-level objects without list wrapping#1541
selamw1 wants to merge 2 commits into
a2ui-project:mainfrom
selamw1:stream-parser-top-level-objects

Conversation

@selamw1
Copy link
Copy Markdown
Collaborator

@selamw1 selamw1 commented Jun 3, 2026

Description

A2UI v0.9 streams use consecutive top-level JSON objects (JSON Lines format) instead of wrapping them in a top-level array [...]. Previously, A2uiStreamParser skipped every character until it saw a [ bracket, causing all v0.9 blocks to be silently discarded.

Fixes #1527

This PR refactors the streaming parser's guard to use a fall-through design:

  1. Allows the parser to recognize top-level objects (starting with { when brace count is 0) directly.
  2. Simplifies the code by letting the standard loop handle brace counting and buffer/stack updates instead of duplicating them.
  3. Adds tests in test_streaming_v09.py to ensure single and consecutive top-level objects are parsed successfully without list wrapping.

Pre-launch Checklist

  • I signed the [CLA].
  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • I have added updates to the [CHANGELOG].
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on fork, I have verified that scripts/e2e_test.sh passes.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the streaming parser to support parsing single and multiple top-level JSON objects without array wrapping, and adds corresponding unit tests. Feedback suggests simplifying a redundant boolean condition in the parser logic to improve readability, and keeping the validator enabled in the new tests to maintain realistic test coverage.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread agent_sdks/python/src/a2ui/parser/streaming.py Outdated
Comment thread agent_sdks/python/tests/parser/test_streaming_v09.py Outdated
Comment thread agent_sdks/python/tests/parser/test_streaming_v09.py Outdated
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.

A2uiStreamParser skips all input when LLM outputs top-level object is {...} instead of array[{...}]

1 participant