Expand description
AWS Lambda adapter for turul-a2a.
Thin wrapper: converts Lambda events to axum requests, delegates to the same Router, converts responses back. Per ADR-008/ADR-009:
- Authorizer context mapped via synthetic headers with anti-spoofing
- Streaming supported via durable event store (D3)
- SSE responses are buffered: task executes, events are collected, returned as one response
POST /message:streamexecutes the task within the Lambda invocation and returns all eventsGET /tasks/{id}:subscribeis for tasks that are not in a terminal state. Within one invocation it emits the initialTasksnapshot, replays stored events viaLast-Event-ID, and closes when the task reaches a terminal state. Subscribing to an already-terminal task returnsUnsupportedOperationErrorper A2A v1.0 §3.1.6 / ADR-010 §4.3. For retrieving a terminal task’s final state useGetTask.
§Push-notification delivery — external triggers are mandatory
Push delivery on Lambda (ADR-013) is architecturally different
from the binary server. The request Lambda installed via
LambdaA2aServerBuilder still constructs a PushDispatcher
when push_delivery_store is wired, but any tokio::spawn
continuation it emits post-return is opportunistic only — the
Lambda execution environment may be frozen indefinitely between
invocations, so nothing can depend on that continuation completing
(ADR-013 §4.4).
Correctness for push delivery on Lambda is carried by:
- The atomic pending-dispatch marker written inside the request
Lambda’s commit transaction (ADR-013 §4.3 — opt in via
StorageImpl::with_push_dispatch_enabled(true)). LambdaStreamRecoveryHandler— DynamoDB Streams trigger ona2a_push_pending_dispatches. DynamoDB backends only.LambdaScheduledRecoveryHandler— EventBridge Scheduler backstop. Required for all backends; it is the sole recovery path for SQLite / PostgreSQL / in-memory deployments.
Without at least the scheduled worker, push delivery on Lambda is
not durable — a marker written on a cold invocation may never be
consumed. The example wiring lives in
examples/lambda-stream-worker and
examples/lambda-scheduled-worker.
Lambda streaming is request-scoped (not persistent SSE connections). The durable
event store ensures events survive across invocations. Clients reconnect with
Last-Event-ID for continuation.
§Cross-instance cancellation
Lambda invocations are stateless and short-lived, so the Lambda
adapter does not run the persistent cross-instance cancel
poller that A2aServer::run() spawns. Cancellation behaviour on
the Lambda adapter:
- Marker writes —
CancelTaskon a Lambda invocation writes the cancel marker to the shared backend (DynamoDB / PostgreSQL). This works. - Propagation to a live executor on the SAME Lambda invocation —
works via the same-instance token-trip path in
core_cancel_task. - Propagation to a live executor on a DIFFERENT Lambda invocation (warm container) — not currently supported. There is no persistent poller to observe markers written by other invocations. A subsequent invocation whose handler reads the marker directly may act on it, but that is not a substitute for the server runtime’s live propagation.
The builder still requires an A2aCancellationSupervisor
implementation on the same backend so that marker writes reach
the correct backend and a future polling-adapter variant can
consume them. If a deployment passes a non-matching supervisor,
build() rejects the configuration.
Structs§
- Authorizer
Mapping - Mapping configuration for Lambda authorizer context.
- Lambda
A2aHandler - Lambda handler wrapping the axum Router.
- Lambda
A2aServer Builder - Builder for Lambda A2A handler.
- Lambda
Authorizer Middleware - Middleware that reads trusted authorizer context from x-authorizer-* headers.
- Lambda
Scheduled Recovery Config - Configuration for a scheduled-recovery sweep.
- Lambda
Scheduled Recovery Handler - Handler for scheduled push-recovery ticks.
- Lambda
Scheduled Recovery Response - Summary returned from a single scheduled-recovery tick.
- Lambda
Stream Recovery Handler - Handler for DynamoDB Stream events on
a2a_push_pending_dispatches. - NoStreaming
Layer - Tower Layer that rejects streaming paths on Lambda.
Functions§
- axum_
to_ lambda_ response - Convert an axum response to a Lambda HTTP response.
- lambda_
to_ axum_ request - Convert a Lambda HTTP request to an axum request.