Skip to content

[Enhancement]: Deliver a reusable opt-in event-driven HTTP server runtime #270

Open

Description

@MisterVVP

Problem

The SDK's HTTP server adapter reads and writes through a synchronous HttpByteTransport. The local SUT HTTP listener likewise uses blocking accepted sockets and a thread per connection. This is adequate for compatibility testing, but makes many concurrent or idle connections expensive and can distort transport benchmarks.

A reusable SDK server runtime should handle network I/O without holding a thread for each connection, while existing synchronous users continue to work unchanged.

Goal

Provide a parallel, opt-in event-driven HTTP server runtime for HTTP+JSON, JSON-RPC and SSE, with bounded network/application resources, portable shutdown and cancellation, and reuse of the SDK's existing routing, validation, and protocol logic.

The server-side network implementation should be shared wherever practical by normal SDK use and performance test fixtures. Do not build separate, independently maintained implementations solely for the SUT and for production applications.

Ownership and issue boundaries (v0.6.0)

Owns: Reusable opt-in inbound event-driven HTTP/1.1 server runtime for HTTP+JSON, JSON-RPC and SSE, including framing, socket scheduling, resource bounds, and integration with existing dispatch/async server contracts.

Prerequisites and integration: PR 1 HTTP codec independent. Unary network PRs can bridge sync work through a bounded off-reactor pool; prefer #268 async dispatcher after its PR 2. SSE streaming integration depends on #169 async stream/session API; neither #269 nor #232 (outbound libcurl) is a prerequisite. #181/#266 are independent persistence work.

Must not absorb: Do not reimplement #268 cancellation/dispatcher or #169 streaming producer; do not modify outbound libcurl, add HTTP/2, build test-only SUT networking or expand async PostgreSQL. PR #281 is test/lesson input, not a patch to merge wholesale.

Issue management: Retain this issue and use separate independently reviewable PRs for the checkpoints below. Close only when final acceptance criteria pass. Do not pull future checkpoints into earlier PRs.

Implementation PR checklist

  • PR 1 — Document portable Linux/macOS/Windows readiness design and deliver byte-oriented incremental HTTP/1.1 codec; independently test fragmentation, content length, pipelining boundaries, malformed input and legacy adapter compatibility.
  • PR 2 — Event-driven accept/read/write for unary HTTP with persistent connections, partial I/O, ordered pipelining, deterministic shutdown and bounded connections/requests/buffers/queues. Route legacy application work to explicitly bounded off-reactor workers.
  • PR 3 — Connect HTTP+JSON, JSON-RPC, agent-card/auth/routes and [Enhancement]: Add opt-in async unary server execution and cancellation #268 async unary dispatch without duplicating protocol validation; native cross-platform socket/overload/idle-client tests.
  • PR 4 — Non-blocking finite/live SSE with [Enhancement]: Add opt-in async server streaming and gRPC callback support #169 stream API, chunked framing, heartbeat, explicit bounded backpressure and cancel/disconnect exactly-once cleanup; tests for slow readers and shutdown races.
  • PR 5 — Opt-in installed-SDK API/example, shared production/SUT runtime integration, c1/c16/c64 plus idle-client CPU/memory/thread/p95/p99 comparisons and full validation.

PR merge rule: Narrow changes, deterministic scope-specific tests, documented lifecycle ownership, and applicable AGENTS.md validation. Measure performance-sensitive behavior against equivalent baseline workloads. Preserve synchronous behavior.

Detailed technical requirements — scope and implementation phases

Phase 1 — Shared codec and runtime design

  • Document the chosen portable readiness/completion mechanism for Linux, macOS and Windows. Do not select a dependency without evaluating its impact on the installed SDK, supported platforms, and non-networked users.
  • Provide incremental HTTP/1.1 request parsing and reusable response encoding that operate on supplied bytes and preserve the validation already enforced by HttpAdapter.
  • Keep existing blocking ReadRequest/WriteResponse APIs source-compatible, ideally reusing the same validation/framing helpers.
  • Preserve request-size limits, Content-Length, connection-close semantics, fragmented bodies, pipelining boundaries and malformed-request handling.
  • Independently unit-test the codec before implementing socket scheduling.

Checkpoint: Codec changes are reviewable without any new networking loop or SSE behavior.

Phase 2 — Event-driven unary HTTP

  • Implement readiness/completion-driven accept, read and write handling; do not poll on fixed sleep intervals or create one OS thread per connection.
  • Support sequential and pipelined HTTP/1.1 requests with ordered responses, partial reads/writes, EOF, reset, persistent connection reuse, idle clients, and a deterministic shutdown wakeup.
  • Explicitly bound active connections, pending requests, input/output buffers, and application-worker queue depth. Define the overload response or close policy; one slow peer must not stall other clients.
  • Route requests through existing RestServerTransport, JsonRpcServerTransport, TransportMux, and dispatcher semantics, preserving validation, errors, metadata, extensions, agent-card routes and authentication.
  • Run synchronous legacy executor/store work away from the network I/O loop, using bounded application concurrency. This is a compatibility bridge, not a claim that application execution is fully asynchronous.
  • Add deterministic native socket tests on Linux, macOS and Windows; capture thread count and unary benchmark evidence.

Checkpoint: Unary HTTP+JSON and JSON-RPC work under high connection concurrency without per-connection network threads, and the legacy server path remains unchanged.

Phase 3 — Finite and live SSE

  • Reuse existing HTTP+JSON/JSON-RPC stream event encoding. Add non-blocking chunked output, terminal handling, partial-write continuation, finite-stream connection reuse, and heartbeat scheduling.
  • Integrate the opt-in async streaming contract from [Enhancement]: Add opt-in async server streaming and gRPC callback support #169 for truly event-driven stream production. If a legacy blocking stream is not readiness-capable, retain it on the synchronous compatibility runtime or document a bounded explicit fallback; do not hide one waiting worker per stream in the event loop.
  • Define demand/backpressure and resource limits for both producer queues and socket output. Slow readers must not cause unbounded queued events or memory.
  • On disconnect/cancel, stop production promptly and perform exactly-once cleanup; guarantee correct ordering when cancellation races completion or shutdown.

Checkpoint: Finite and live SSE have independent lifecycle tests; no stream-specific network thread or unbounded queue is introduced.

Phase 4 — SDK integration, documentation and evidence

  • Expose an opt-in API/configuration without replacing HttpAdapter or forcing existing applications to migrate.
  • Add a minimal downstream usage example. If the performance SUT selects this runtime, confine test-only diagnostics, observer semantics and benchmark switches to the SUT layer.
  • Compare c1, c16, c64 and idle-connection scalability with the existing baseline: throughput, unary/first-event/completion p95/p99, errors, CPU, memory, and process threads.
  • Document ownership, thread scheduling, shutdown, buffer limits, cancellation and unsupported configurations.

Relationship to other issues

  • #169 owns async streaming application/session interfaces and gRPC callbacks. This issue owns HTTP network/framing integration.
  • #268 owns async unary executor, dispatcher and cancellation. Integrate when available without making socket readiness depend on completion of all gRPC work.
  • #269 and #232 are outbound client work, not prerequisites for an inbound server.
  • #181/#266 cover optional non-blocking PostgreSQL, not HTTP socket readiness.
  • Closed/unmerged PR #281 is a source of test cases and lessons, not a required design or patch to merge wholesale.

Out of scope

  • Replacing synchronous public APIs, implementing an HTTP/2 stack, rewriting A2A protocol routing, changing gRPC socket scheduling, or adding async PostgreSQL.
  • Replacing client-side libcurl, or introducing a general-purpose HTTP framework unrelated to A2A server requirements.
  • Optimizing unrelated transport or persistence hot paths as part of network-loop changes.

Acceptance criteria

  • Existing sync HttpAdapter callers and existing REST/JSON-RPC applications remain source-compatible.
  • An opt-in runtime serves REST, JSON-RPC, agent-card and finite/live SSE paths correctly.
  • Connection, queue, buffer, and worker usage remain bounded and do not grow one thread per idle connection/stream.
  • Deterministic tests cover fragmented/pipelined requests, partial writes, slow/idle clients, cancellation, live/finite streams and shutdown races on supported OSes.
  • Application code and blocking stores do not run on the socket I/O loop.
  • Required repository validation, interoperability/TCK and performance smoke pass; results are based on comparable configurations.
  • No unexplained material throughput/latency regression, including at low concurrency.
  • Architecture, resource limits and lifecycle contracts are documented.

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 an event-driven HTTP server runtime for REST, JSON-RPC, and SSE[/-] [+][Enhancement]: Deliver a reusable opt-in event-driven HTTP server runtime[/+] on Oct 11, 2026
  4. moved this from Todo to In Progress in a2a-cpp SDK Roadmapon Nov 7, 2026
  5. self-assigned this
    on Nov 7, 2026
  6. linked a pull request that will close this issueRelease v0.6.0 #322on Nov 8, 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