Repository navigation
feat(client): add opt-in async unary operations across transports - #325
Conversation
MisterVVP
left a comment
There was a problem hiding this comment.
This first attempt looks decent, however a few things should be considered:
- are we following RAII rules and especially rules of 3 and 5? ~A2AClient() is introduced, however it's introduced alone! Triple check this and if needed - inhering from NonCopyable or NonCopyableOrMovable
- consider code maintainability and complexity, do we need to bundle async client operations into the same client header? Or can we consider responsibility split for sync/async clients and using composition to inject shared implementations inside both?
- Same consideration as in p2 applies to transports. Think about this from devex and maintainability perspective
- Regarding [async_operation.cpp] and it's header - did we consider Boost library abstractions and implementation? We want to keep balance between writing things on our own and using library implementations.
Compose synchronous and asynchronous interfaces around shared session state and private native transport implementations. Make lifecycle ownership and copy/move policies explicit. Self-review fixes interceptor reentrancy and pairing, gRPC native-call registration exception safety, and shutdown cycles involving gRPC stream and unary callbacks. Document the standard-library runtime decision and refresh benchmark evidence.
|
@codex review this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Adds opt-in callback calls through
client.Async().GetTask(request, completion, options)and the separateAsyncClientheader. All eight unary methods and asynchronous Agent Card discovery are covered. Existing synchronous client methods, transport constructors and streaming observers remain available.Sync and async facades compose one private session for transport ownership, interceptor registration and shutdown.
A2AClienthas a stable, explicitly noncopyable/nonmovable identity;AsyncClientis a copyable view that observes owner shutdown.AsyncClientTransportlives in its own header, and each binding composes a private async implementation in a separate source file. HTTP+JSON/JSON-RPC share their request builders, decoders and existing libcurl reactors; gRPC shares metadata/deadline/error helpers and uses native callback unary calls. Synchronous transport wrappers follow the Rule of Zero and share their async component when copied.Accepted calls complete exactly once away from network threads, with cancellation, deadlines, bounded admission and draining/reentrant shutdown. Self-review also fixed interceptor reentrancy and pairing through per-call snapshots, made gRPC native-call registration exception-safe through RAII, and covered shutdown from both gRPC streaming callbacks while a unary callback depends on the stream callback returning.
A second self-review contains throwing async Agent Card verifiers as immediate internal errors, revalidates cache hits with the same verifier snapshot, and drains active verifier hooks during external shutdown and destruction of the last owning discovery-client copy without deadlocking reentrant shutdown. Copies retain shared operation ownership and remain usable when another copy is destroyed. Timer admission now rolls back on index-allocation failure, and deadline expiry reuses its admitted timer node. Six new regressions cover verifier errors/cache revalidation, external/reentrant discovery shutdown and last-copy destruction, and once-only deadline-batch completion with admission recovery.
The completion layer remains standard C++: adopting Boost.Asio here would turn the optional server dependency into a core dependency while still requiring SDK-specific admission, result selection and native cancellation/lifetime rules. The guide records this decision, ownership rules, custom transport injection, examples and measured tradeoffs.
At concurrency 32, sampled client thread counts were 37/10 for HTTP sync/async and 40/15 for gRPC. Throughput varied by binding and concurrency; async adds dispatch costs at low concurrency. Equivalent release-baseline/candidate synchronous parsing measurements ranged from -4.5% to +3.3%, within all six existing absolute thresholds. The guide includes the full selected results and workload limits.
Implements #269 in one PR, targeting
release/v0.6.0.Validation:
./scripts/verify_changes.sh: 864 tests, zero failures (four conditional/inapplicable skips), formatting, build and split clang-tidy profiles../scripts/run_clang_tidy.sh build.mdbook build book.TCK is not green: unmodified upstream
104a7b4ae0d83f65c075e3793e322953a830eabareports 242 passed, 17 skipped and four failures. These match the release branch's documented upstream defects: missingexpected_errorfor CORE-SEND-003 on all three bindings, plus contradictory AIP-193/media-type assertions. Mandatory requirement coverage is 82.7%; requirements without upstream fixtures remain NOT TESTED. No assertions, skip rules or exit statuses were changed. The maintainer explicitly approved an exception to the repository's 100% TCK publication gate for these documented baseline failures and coverage gaps. The final TCK run matches this approved baseline. Issue #269 remains open at the maintainer's request.