Skip to content

feat(client): add opt-in async unary operations across transports - #325

Merged
MisterVVP merged 4 commits into
release/v0.6.0from
feat/269-async-unary
Nov 7, 2026
Merged

MisterVVP merged 4 commits into
release/v0.6.0from
feat/269-async-unary

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Adds opt-in callback calls through client.Async().GetTask(request, completion, options) and the separate AsyncClient header. 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. A2AClient has a stable, explicitly noncopyable/nonmovable identity; AsyncClient is a copyable view that observes owner shutdown. AsyncClientTransport lives 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:

  • CI on the final commit: all 15 jobs passed, including Linux, both macOS configurations, Windows, installed consumers, sanitizers, ThreadSanitizer, coverage, interoperability and performance. CodeQL, documentation, tutorials and commit-message checks also passed.
  • ./scripts/verify_changes.sh: 864 tests, zero failures (four conditional/inapplicable skips), formatting, build and split clang-tidy profiles.
  • Exact CI formatting check and ./scripts/run_clang_tidy.sh build.
  • Focused ASan/UBSan profile: 80 tests, zero failures (one inapplicable binding skip), including native stream/unary shutdown cycles.
  • libcurl-disabled build and example smoke; installed async unary consumer; mdbook build book.
  • Required gRPC/HTTP performance smoke: zero errors. All 18 live network benchmark cases: zero errors. Parsing benchmarks pass existing thresholds.
  • Dependency vulnerability scan: no findings in supported manifests; no new third-party dependencies.

TCK is not green: unmodified upstream 104a7b4ae0d83f65c075e3793e322953a830eaba reports 242 passed, 17 skipped and four failures. These match the release branch's documented upstream defects: missing expected_error for 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.

@MisterVVP MisterVVP added the AI agent AI agent contribution label Nov 7, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Nov 7, 2026
@MisterVVP MisterVVP added the performance Performance improvement related tasks based on benchmark results. Performance tests changes. label Nov 7, 2026

@MisterVVP MisterVVP left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This first attempt looks decent, however a few things should be considered:

  1. 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
  2. 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?
  3. Same consideration as in p2 applies to transports. Think about this from devex and maintainability perspective
  4. 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.
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T17:27:46.538890Z b018680 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: b018680a96

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@MisterVVP
MisterVVP merged commit 6954748 into release/v0.6.0 Nov 7, 2026
22 of 23 checks passed
@MisterVVP
MisterVVP deleted the feat/269-async-unary branch November 7, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution performance Performance improvement related tasks based on benchmark results. Performance tests changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant