Skip to content

[Enhancement]: Add opt-in async unary server execution and cancellation #268

Description

@MisterVVP

Problem

The current server path is synchronous: transport → Dispatcher::Dispatch → AgentExecutor. Blocking unary operations hold a calling thread, and request cancellation/deadlines are not exposed through a transport-independent application execution contract. A non-blocking socket layer alone does not fix this.

Goal

Add a parallel opt-in async unary executor/dispatcher path with explicit cancellation and deadline propagation, then support it via native gRPC callback execution. Keep existing synchronous interfaces source-compatible and avoid one SDK worker thread per asynchronous request.

Ownership and issue boundaries (v0.6.0)

Owns: Transport-independent server request cancellation/deadline context, opt-in async unary executor/dispatcher, and native gRPC unary callbacks. This issue defines the canonical server request-lifecycle semantics.

Prerequisites and integration: No prerequisite for PR 1. Coordinate the request context with #169; #270 consumes the dispatcher after PR 2. #269 shares conventions but is not a network dependency. #181/#266 are independent.

Must not absorb: Do not implement stream sessions (#169), HTTP framing/socket scheduling (#270), outbound clients (#269) or async database stores (#266). Preserve sync code paths.

Issue management: Keep this single issue; each checkbox below is intended as a separately reviewable PR. Do not implement later checkpoints in an earlier PR just to close the issue faster. Close the issue only after the final acceptance criteria pass.

Implementation PR checklist

  • PR 1 — Request-context and cancellation/deadline contract with deterministic lifetime/race unit tests; no transport changes.
  • PR 2 — Opt-in unary executor and dispatcher with shared validation/interceptors and fake-transport tests for every operation; no native socket changes.
  • PR 3 — Native gRPC async unary callbacks with metadata/deadline/error mapping and shutdown/cancellation tests.
  • PR 4 — Downstream usage docs, supported-platform/installed-consumer validation, and sync-vs-async thread/latency evidence.

PR merge rule: Each PR must have a narrow diff, behavior/lifecycle tests for its scope, and the applicable repository checks from AGENTS.md. Benchmark performance-sensitive changes against equivalent baseline configurations. Never describe blocking worker adaptation as non-blocking network/database I/O.

Detailed technical requirements and implementation phases

Phase 1 — Request cancellation and deadline contract

  • Introduce a transport-independent cancellation/deadline state that remains valid throughout an in-flight operation, with a small application-facing API.
  • Define the distinction between client cancellation, deadline expiry and application failure; specify completion-vs-cancel precedence and exactly-once completion.
  • Preserve existing request metadata, auth and headers; do not require synchronous executors to know about new state.
  • Test pre-cancellation, concurrent cancel/completion, deadline, shutdown and observer lifetime using deterministic synchronization.

Checkpoint: Context and cancellation behavior are testable without refactoring the dispatcher or gRPC transports.

Phase 2 — Opt-in async executor and dispatcher

  • Add a parallel async executor contract for unary operations: SendMessage, GetTask, ListTasks, CancelTask, push-notification configuration create/get/list/delete, and extended agent-card retrieval where dispatched.
  • Share current payload validation, required extensions, interceptors, error mapping, history-retention behavior and agent-card logic with synchronous dispatch. Do not fork a second large protocol switch with divergent semantics.
  • Define continuation/completion scheduling: application callbacks and interceptors must not block network reactor threads; BeforeDispatch precedes execution, AfterDispatch runs exactly once after completion/cancel/error.
  • Avoid a dedicated thread per call. If a legacy synchronous executor is supported as a compatibility fallback, it must use an explicitly bounded worker facility and must not be presented as non-blocking application execution.
  • Add tests for all operations, errors, interceptors, cancellation, completion races and executor destruction/shutdown.

Checkpoint: Async dispatch works with a fake transport, and sync dispatch remains unchanged.

Phase 3 — gRPC unary callbacks

  • Connect the new async dispatcher to native gRPC callback/asynchronous unary APIs without blocking callback threads.
  • Propagate gRPC deadlines, cancellation, metadata/auth and extension activation; preserve the status mapping used by the existing sync transport.
  • Test concurrent requests, cancel/deadline racing with completion, shutdown, and bounded SDK thread growth.
  • Document separate sync and async registration options, not a forced migration.

Relationship to other issues

  • #270 implements event-driven HTTP network I/O. Its later unary integration should use this executor contract; the HTTP socket layer need not wait for every gRPC stage here.
  • #169 owns async streaming and gRPC server-streaming callbacks.
  • #181/#266 cover conditional non-blocking PostgreSQL stores; this issue must not introduce new database I/O implementations.
  • Coordinate asynchronous completion conventions with #269, without coupling server and client transport releases unnecessarily.

Out of scope

  • Replacing AgentExecutor or the existing synchronous Dispatcher.
  • HTTP socket implementation, streaming session redesign, async PostgreSQL, or changing A2A protocol semantics.
  • Implementing the async path as std::async / one blocked worker thread for every request.

Acceptance criteria

  • Existing synchronous APIs and current TCK behavior stay source-compatible.
  • All existing unary dispatcher operations are supported by the opt-in async executor.
  • Protocol validation/error mapping and interceptor ordering match the synchronous path.
  • Transport-neutral cancellation and deadlines are observable by applications, valid for the entire operation and race-safe.
  • Exactly-once completion/AfterDispatch and deterministic shutdown are demonstrated in tests.
  • Native gRPC async unary execution does not block reactor threads or allocate one SDK worker per in-flight operation.
  • Representative concurrency tests, mandatory TCK, platform builds and required performance checks pass.

Activity

  1. added this to the v0.6.0 milestone on Oct 5, 2026
  2. added
    enhancement
    on Oct 5, 2026
  3. changed the title [-][Enhancement]: Add opt-in asynchronous unary server execution and cancellation propagation[/-] [+][Enhancement]: Add opt-in async unary server execution and cancellation[/+] on Oct 11, 2026
  4. self-assigned this
    on Oct 26, 2026
  5. moved this from Todo to In Progress in a2a-cpp SDK Roadmapon Oct 28, 2026
  6. linked a pull request that will close this issueRelease v0.6.0 #322on Nov 1, 2026
  7. moved this from In Progress to In Review in a2a-cpp SDK Roadmapon Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions