Agent-plugins aws-lambda-durable-functions
git clone https://github.com/awslabs/agent-plugins
T=$(mktemp -d) && git clone --depth=1 https://github.com/awslabs/agent-plugins "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/aws-serverless/skills/aws-lambda-durable-functions" ~/.claude/skills/awslabs-agent-plugins-aws-lambda-durable-functions && rm -rf "$T"
plugins/aws-serverless/skills/aws-lambda-durable-functions/SKILL.mdAWS Lambda durable functions
Build resilient multi-step applications and AI workflows that can execute for up to 1 year while maintaining reliable progress despite interruptions.
Onboarding
Step 1: Validate Prerequisites
Before using AWS Lambda durable functions, verify:
-
AWS CLI is installed (2.33.22 or higher) and configured:
aws --version aws sts get-caller-identity -
Runtime environment is ready:
- For TypeScript/JavaScript: Node.js 22+ (
)node --version - For Python: Python 3.11+ (
. Note that currently only Lambda runtime environments 3.13+ come with the Durable Execution SDK pre-installed. 3.11 is the min supported Python version by the Durable SDK itself, however, you could use OCI to bring your own container image with your own Python runtime + Durable SDK.)python --version
- For TypeScript/JavaScript: Node.js 22+ (
-
Deployment capability exists (one of):
- AWS SAM CLI (
) 1.153.1 or highersam --version - AWS CDK (
) v2.237.1 or highercdk --version - Direct Lambda deployment access
- AWS SAM CLI (
Step 2: Select language and IaC framework
Language Selection
Default: TypeScript
Override syntax:
- "use Python" → Generate Python code
- "use JavaScript" → Generate JavaScript code
When not specified, ALWAYS use TypeScript
IaC framework selection
Default: CDK
Override syntax:
- "use CloudFormation" → Generate YAML templates
- "use SAM" → Generate YAML templates
When not specified, ALWAYS use CDK
Error Scenarios
Unsupported Language
- List detected language
- State: "Durable Execution SDK is not yet available for [framework]"
- Suggest supported languages as alternatives
Unsupported IaC Framework
- List detected framework
- State: "[framework] might not support Lambda durable functions yet"
- Suggest supported frameworks as alternatives
Serverless MCP Server Unavailable
- Inform user: "AWS Serverless MCP not responding"
- Ask: "Proceed without MCP support?"
- DO NOT continue without user confirmation
Step 3: Install SDK
For TypeScript/JavaScript:
npm install @aws/durable-execution-sdk-js npm install --save-dev @aws/durable-execution-sdk-js-testing
For Python:
pip install aws-durable-execution-sdk-python pip install aws-durable-execution-sdk-python-testing
When to Load Reference Files
Load the appropriate reference file based on what the user is working on:
- Getting started, basic setup, example, ESLint, or Jest setup -> see getting-started.md
- Understanding replay model, determinism, or non-deterministic errors -> see replay-model-rules.md
- Creating steps, atomic operations, or retry logic -> see step-operations.md
- Waiting, delays, callbacks, external systems, or polling -> see wait-operations.md
- Parallel execution, map operations, batch processing, or concurrency -> see concurrent-operations.md
- Error handling, retry strategies, saga pattern, or compensating transactions -> see error-handling.md
- Advanced error handling, timeout handling, circuit breakers, or conditional retries -> see advanced-error-handling.md
- Testing, local testing, cloud testing, test runner, or flaky tests -> see testing-patterns.md
- Deployment, CloudFormation, CDK, SAM, log groups, deploy, or infrastructure -> see deployment-iac.md
- Advanced patterns, GenAI agents, completion policies, step semantics, or custom serialization -> see advanced-patterns.md
- troubleshooting, stuck execution, failed execution, debug execution ID, or execution history -> see troubleshooting-executions.md
Quick Reference
Basic Handler Pattern
TypeScript:
import { withDurableExecution, DurableContext } from '@aws/durable-execution-sdk-js'; export const handler = withDurableExecution(async (event, context: DurableContext) => { const result = await context.step('process', async () => processData(event)); return result; });
Python:
from aws_durable_execution_sdk_python import durable_execution, DurableContext @durable_execution def handler(event: dict, context: DurableContext) -> dict: result = context.step(lambda _: process_data(event), name='process') return result
Critical Rules
- All non-deterministic code MUST be in steps (Date.now, Math.random, API calls)
- Cannot nest durable operations - use
to group operationsrunInChildContext - Closure mutations are lost on replay - return values from steps
- Side effects outside steps repeat - use
(replay-aware)context.logger
Python API Differences
The Python SDK differs from TypeScript in several key areas:
- Steps: Use
decorator +@durable_step
, or inlinecontext.step(my_step(args))
. Prefer the decorator for automatic step naming.context.step(lambda _: ..., name='...') - Wait:
context.wait(duration=Duration.from_seconds(n), name='...') - Exceptions:
(permanent),ExecutionError
(transient),InvocationError
(callback failures)CallbackError - Testing: Use
class directly - instantiate with handler, use context manager, callDurableFunctionTestRunnerrun(input=...)
Invocation Requirements
Durable functions require qualified ARNs (version, alias, or
$LATEST):
# Valid aws lambda invoke --function-name my-function:1 output.json aws lambda invoke --function-name my-function:prod output.json # Invalid - will fail aws lambda invoke --function-name my-function output.json
IAM Permissions
Your Lambda execution role MUST have the
AWSLambdaBasicDurableExecutionRolePolicy managed policy attached. This includes:
- Persist execution statelambda:CheckpointDurableExecution
- Retrieve execution statelambda:GetDurableExecutionState- CloudWatch Logs permissions
Additional permissions needed for:
- Durable invokes:
on target function ARNslambda:InvokeFunction - External callbacks: Systems need
andlambda:SendDurableExecutionCallbackSuccesslambda:SendDurableExecutionCallbackFailure
Validation Guidelines
When writing or reviewing durable function code, ALWAYS check for these replay model violations:
- Non-deterministic code outside steps:
,Date.now()
, UUID generation, API calls, database queries must all be inside stepsMath.random() - Nested durable operations in step functions: Cannot call
,context.step()
, orcontext.wait()
inside a step function — usecontext.invoke()
insteadcontext.runInChildContext() - Closure mutations that won't persist: Variables mutated inside steps are NOT preserved across replays — return values from steps instead
- Side effects outside steps that repeat on replay: Use
for logging (it is replay-aware and deduplicates automatically)context.logger
When implementing or modifying tests for durable functions, ALWAYS verify:
- All operations have descriptive names
- Tests get operations by NAME, never by index
- Replay behavior is tested with multiple invocations
- Use
for local testingLocalDurableTestRunner
MCP Server Configuration
Write access is enabled by default. The plugin ships with
--allow-write in .mcp.json, so the MCP server can create projects, generate IaC, and deploy on behalf of the user.
Access to sensitive data (like Lambda and API Gateway logs) is not enabled by default. To grant it, add
--allow-sensitive-data-access to .mcp.json.