Skip to content

Kotlin sdk treeshake s2c messages#1396

Open
jgindin wants to merge 3 commits into
google:mainfrom
jgindin:kotlin-sdk-treeshake-s2c-messages
Open

Kotlin sdk treeshake s2c messages#1396
jgindin wants to merge 3 commits into
google:mainfrom
jgindin:kotlin-sdk-treeshake-s2c-messages

Conversation

@jgindin
Copy link
Copy Markdown
Collaborator

@jgindin jgindin commented May 11, 2026

Description

Implement coordinated component and message pruning via withPruning, propagating allowedMessages from A2uiSchemaManager down to Catalog.

Enable full conformance verification.

Port of Python SDK commit 0fd7240

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

@jgindin jgindin requested a review from nan-yu May 11, 2026 16:24
@jgindin jgindin self-assigned this May 11, 2026
@github-project-automation github-project-automation Bot moved this to Todo in A2UI May 11, 2026
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 introduces a streaming parser for A2UI, supporting both v0.8 and v0.9 specifications, along with enhanced schema pruning capabilities for components, messages, and common types. Key additions include the StreamingParser base class and its version-specific implementations, as well as the TopologyAnalyzer and SchemaInspector for managing component relationships. Feedback focuses on critical performance and security optimizations within the streaming logic. Specifically, the reviewer identified high-severity inefficiencies in the JSON sniffing logic, such as redundant regex searches and object allocations in hot loops. Additionally, there are concerns regarding potential memory exhaustion from unbounded buffers and stack overflow risks due to recursive schema traversal on untrusted input.

Comment thread agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/parser/StreamingParser.kt Outdated
Comment thread agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/parser/StreamingParser.kt Outdated
Comment thread agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/parser/StreamingParser.kt Outdated

protected var foundDelimiter = false
protected var buffer = ""
protected var jsonBuffer = ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

jsonBuffer is appended to continuously as chunks are processed and is only reset when a closeTag is encountered. If a malicious or malformed stream provides a very large A2UI block without a closing tag, this buffer will grow indefinitely, potentially leading to an OutOfMemoryError. Consider implementing a maximum buffer size limit.

Comment thread agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/schema/Catalog.kt Outdated
@jgindin jgindin force-pushed the kotlin-sdk-treeshake-s2c-messages branch 3 times, most recently from d8ac73a to b225336 Compare May 12, 2026 15:51
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar comment as the previous one. Ideally, we should not need any unit tests for the treeshaking feature.

@jgindin jgindin force-pushed the kotlin-sdk-treeshake-s2c-messages branch 5 times, most recently from 624b953 to f1e3968 Compare May 15, 2026 20:37
jgindin added 3 commits May 15, 2026 16:39
Implements the full incremental A2UI v0.9 streaming parser suite in
Kotlin, achieving SDK parity. Automatically incorporates critical
subsequent fixes for robust real-time topology parsing and relative
bindings.

Port of Python SDK commit 8ba982a
Port of Python SDK commit 1ea689d
Implement coordinated component and message pruning via withPruning,
propagating allowedMessages from A2uiSchemaManager down to Catalog.

Add robust automated unit tests and enable full conformance
verification.

Port of Python SDK commit 0fd7240
@jgindin jgindin force-pushed the kotlin-sdk-treeshake-s2c-messages branch from f1e3968 to 6897fe5 Compare May 15, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants