Expand description
AWS Lambda adapter for turul-a2a: it feeds
Lambda events to the same axum router the binary server uses, so one
AgentExecutor runs unchanged
behind a Function URL, API Gateway, ALB or SQS.
Use it to deploy an A2A agent as a Lambda function; executor, storage and
middleware come from turul-a2a.
§Example
[dependencies]
turul-a2a = "0.2"
turul-a2a-proto = "0.2"
turul-a2a-aws-lambda = "0.2"
async-trait = "0.1"
lambda_runtime = "1"
tokio = { version = "1", features = ["full"] }use turul_a2a::storage::InMemoryA2aStorage;
use turul_a2a_aws_lambda::LambdaA2aServerBuilder;
#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
// In-memory storage suits a demo; use a shared backend in production.
LambdaA2aServerBuilder::new()
.executor(Echo)
.storage(InMemoryA2aStorage::new())
.run()
.await
}§Choosing a runner
LambdaA2aServerBuilder::run is the default entry point. Without the
sqs feature it is run_http_only; with it, run_http_and_sqs, which
accepts either event shape. The named runners are strict and fail on any
other shape: run_http_only (Function URL / API Gateway),
run_sqs_only and run_http_and_sqs (both sqs). For a third trigger,
match on classify_event yourself and pass HTTP events to
LambdaA2aHandler::handle_http_event_value.
Behind a REST API Gateway stage, set
LambdaA2aServerBuilder::strip_path_prefix so the router sees root-rooted paths.
§Lambda behaviour
- SSE responses are buffered: the task runs, its events are collected, and
one response is returned.
GET /tasks/{id}:subscribeserves tasks that are not yet terminal and closes on a terminal state orINPUT_REQUIRED. - Push-notification delivery cannot rely on work continuing after the
response. Recovery is carried by
LambdaScheduledRecoveryHandler(required on every backend) and, on DynamoDB,LambdaStreamRecoveryHandler. - No cross-instance cancel poller runs.
CancelTaskwrites its marker to the shared backend, but a live executor on a different invocation does not observe it.
§Features
| Feature | Enables |
|---|---|
sqs | SQS-backed durable executor and the SQS runners |
dynamodb | turul-a2a’s DynamoDB backend |
§Where next
LambdaAuthorizerMiddlewareto map an API Gateway authorizer to a caller identitylambda-agentand the worker examples on GitHub
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.
Enums§
- Lambda
Event - Coarse Lambda event-shape discriminator returned by
classify_event.
Functions§
- axum_
to_ lambda_ response - Convert an axum response to a Lambda HTTP response.
- classify_
event - Classify a raw Lambda event JSON shape.
- handle_
maintenance_ trigger - Run one retention-maintenance sweep, invoked by an EventBridge Scheduler rule.
- lambda_
to_ axum_ request - Convert a Lambda HTTP request to an axum request.