Skip to content

feat(server): add opt-in async unary executor and dispatcher - #316

Merged
MisterVVP merged 2 commits into
feat/async-serverfrom
feat/async-unary-dispatch-268
Oct 28, 2026
Merged

MisterVVP merged 2 commits into
feat/async-serverfrom
feat/async-unary-dispatch-268

Conversation

@MisterVVP

Copy link
Copy Markdown
Owner

Summary

Implements Phase 2 / PR 2 of #268 against feat/async-server. Applications can initiate unary work and return immediately, then complete it from any thread through the new opt-in a2a::server::engine::AsyncAgentExecutor and AsyncDispatcher.

  • Supports SendMessage, GetTask, ListTasks, CancelTask, push-config create/get/list/delete, and extended agent cards through the existing provider.
  • Extracts one shared typed operation router and pipeline for sync/async payload checks, security, interceptor ordering, agent-card retrieval, and history projection. Required extensions use the existing validator. Public synchronous APIs remain source-compatible; each dispatch snapshots its interceptor list.
  • Uses a fixed worker pool and bounded in-flight admission. Pending application work holds no SDK worker. Executor initiation, hooks, policies/providers, and transport completion run on workers. The existing inline, non-blocking stop-observer contract is retained.
  • Delivers one terminal completion and one reverse-order AfterDispatch pass, including errors/cancellation. Completion receives an owned lifecycle context, so it is safe even before Dispatch returns its cancellation handle. Deadlines remain transport-driven, with start/completion checks.
  • Handles shutdown, late/duplicate replies, executor release, and dispatcher destruction from completion/cancellation observers. The existing security/store and agent-card provider facilities run on bounded workers; they retain their synchronous contracts.

Adds API/threading documentation and immediate-result microbenchmarks. Native transport registration remains PR 3; #268 stays open.

Authorship and AI usage

  • Contains substantive content written by a human
  • Contains substantive content generated by an AI agent

Testing

  • A2A_VERIFY_POSTGRES=1 A2A_VERIFY_BUILD_DIR=build ./scripts/verify_changes.sh — passed; 839 tests.
  • Exact ./scripts/run_clang_tidy.sh build and CI clang-format --dry-run --Werror mechanism — passed. New benchmark also passed targeted clang-tidy.
  • 49 fake-transport/component tests, covering every operation, errors, metadata, security/history, extensions, admission, lifecycle races, and shutdown; 50 consecutive runs passed before the final test-guard cleanup.
  • TCK via run_tck_sut.sh / run_tck_mandatory.sh / stop_tck_sut.sh, with grpc/jsonrpc/http_json: 249 passed, 16 conditional skips on each of PostgreSQL and in-memory stores.
  • mdbook build book — passed.
  • Required performance smoke: 54 rows, 0 errors.
  • Python dependency audit — no known vulnerabilities. Native OSV scanning was attempted but this environment blocks api.osv.dev; SDK dependency versions are unchanged.

The TCK retains the previously approved baseline from PR #315: 80.9% MUST / 80.0% overall coverage, with 21 registered MUST requirements lacking upstream tests. All executable tests passed; this is not a claim of 100% specification compliance. Upstream TCK revision: d4d6fae7887f88ef607fb461c13e3b0e1802f19b.

Performance evidence

RelWithDebInfo, GCC 15, identical immediate in-memory GetTask response, one outstanding request, no interceptors/security; five repetitions with a 0.2 s minimum. The base comparison links the original dispatcher from 44d927b with the same fixture and dependencies.

Path Median wall time
Original synchronous dispatcher 0.408 µs
Shared synchronous pipeline 0.631 µs
Async dispatcher, one SDK worker 19.690 µs

The shared sync path adds approximately 0.22 µs (+55%) in this microbenchmark, recorded explicitly for review. Async timing includes admission, lifecycle, queue scheduling and the benchmark's future-based reply handoff. These measurements cover immediate-result overhead; broader concurrency/latency evidence remains PR 4. The fake transport tests independently prove 32 pending operations can initiate on at most two SDK workers.

Checklist

  • ./scripts/verify_changes.sh passed locally
  • Docs updated if behavior changed

@MisterVVP MisterVVP added the AI agent AI agent contribution label Oct 28, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Owner Author

@MisterVVP ready for review. This implements Phase 2 / PR 2 of #268 against feat/async-server. Validation, the approved TCK baseline, and the measured sync/async dispatcher overhead are documented in the PR description.

@MisterVVP MisterVVP self-assigned this Oct 28, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T12:17:58.247810Z fa48d00 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. What shall we delve into next?

Reviewed commit: fa48d00547

ℹ️ 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 3ebf415 into feat/async-server Oct 28, 2026
22 checks passed
@MisterVVP
MisterVVP deleted the feat/async-unary-dispatch-268 branch October 28, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant