Initial C++ port of the python agent SDKs#1254
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the A2UI C++ SDK, featuring schema management, message validation, and streaming parsing, along with a CMake build system and Python-based schema embedding. Feedback highlights security risks and performance overhead from hardcoded temporary file logging, portability concerns in the CMake configuration, and performance bottlenecks caused by excessive deep copies of JSON structures. Additionally, it is recommended to strengthen validation by raising errors for malformed components.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the initial implementation of the A2UI C++ SDK, providing core functionality for schema management, message validation, and streaming parsing. The changes include a CMake build system, a Python script for embedding JSON schemas, and a comprehensive suite of unit and conformance tests. Review feedback highlights several performance optimization opportunities within the streaming parser, specifically regarding the frequent construction of regex objects and redundant JSON parsing. Additionally, the reviewer recommended using C++17 string_view for global constants and noted an unimplemented method in the template manager that requires attention.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the C++ SDK for A2UI, featuring a CMake build system, schema management, validation logic, and a streaming parser supporting v0.8 and v0.9 specifications. Feedback focuses on improving code robustness and maintainability: specifically, handling plain text gracefully in the response parser, moving implementation details from headers to source files to optimize build times, using CMake's Python discovery instead of hardcoded commands, and replacing magic numbers and global string constants with more idiomatic C++ alternatives. Consolidating duplicate test helpers was also recommended.
|
CC: @wrenj |
wrenj
left a comment
There was a problem hiding this comment.
hi nan, i didn't look too closely but as a straight port of the python sdk this works for me. i assume test cases were all ported and cover everything?
Yes, most the heavy-lifting logic—specifically the validator and stream parser—has been converted into unified conformance tests for full coverage. Regarding the schema_manager and catalog tests: they are currently only partially covered. I’m planning to convert these into the conformance test style next. This avoids the overhead of a straight port followed by an immediate refactor. |
…terface methods to std::string_view
…cursion depth constants in validator
…in streaming parser
… google-adk dependency
|
#1266 covers the remaining tests. I'm going to merge this PR. |
Description
Summary of Changes
This pull request introduces a C++ implementation of the agent SDK, enabling C++ applications to interact with A2UI-based agents. The implementation focuses on providing essential schema management, streaming response parsing, and payload validation, mirroring the functionality of the existing Python SDK while omitting packages with external Python dependencies. The changes include a complete build system setup, core library logic, and a suite of tests to ensure protocol conformance.
Highlights
C++ SDK Implementation: Introduced a new C++ port of the agent SDK, providing core schema management, parsing, and validation capabilities.
Streaming Parser: Added a robust streaming parser for A2UI messages, supporting both v0.8 and v0.9 protocols with built-in deduplication and topology validation.
Build System: Configured CMake with FetchContent for dependency management and added a Python script to automate the generation of embedded schemas.
Validation Logic: Implemented comprehensive validation for A2UI payloads, including structural integrity checks, recursion limits, and topology verification.
Note: The C++ version of validator behaves the same way as the Python validator because both pass the same conformance tests. However, they don't have implementation parity. Python relies heavily on external schema definitions, while C++ relies on manual traversal and checks. I tried to use the widely adopted
json-schema-validatorin C++ to match Python's use ofjsonschema. However, the C++ library failed to resolve references like/$defs/anyComponentbecause it only supports Draft 7 of JSON schema (Draft 2020-12 support: Draft 2020-12 conformance pboettch/json-schema-validator#373), while the A2UI v0.9 spec uses Draft 2020-12 features like$def.As of today (April 23, 2026), the only C++ library that specifically lists support for Draft 2020-12 is https://github.com/danielaparker/jsoncons. However, it is not available in the internal Google codebase. Therefore, we decided to stick to the current manual validation approach, which makes the C++ version more lenient on malformed payloads.
Exception: The
a2aandadkpackages are not ported due to external Python dependencies.adkdepends ongoogle-adk, which doesn't support C++.a2adepends ona2a-sdk, which provides types likePart,DataPartandTextPartfor Agent-to-Agent messaging. There is no official standalone C++ SDK.Our downstream customers only require the validation part from the C++ SDK. Therefore, we skip the adk and a2a extension for now.
List which issues are fixed by this PR. For larger changes, raising an issue first helps reduce redundant work.
Pre-launch Checklist
If you need help, consider asking for advice on the discussion board.