Skip to content

Lambda

Serverless: no GPU, no instance to reserve, nothing standing between requests. The SDK’s deploy/lambda/ CDK stack builds an arm64 image with the 2B Qwen3.5 Decider baked in (LoRA merged into the torso, quantized to Q8_0 for llama.cpp) and creates one Lambda function behind an IAM-authenticated Function URL. Requests take seconds.

  • When to pick it: triage, moderation, routing queues, batch scoring, pre-action checks — decisions that can wait seconds, at volumes where a GPU would sit idle. For a per-tool-call guard inside an agent loop, serve on a GPU instead.

Requires an AWS account, Node.js 22+, awscurl + AWS CLI v2 for testing.

Terminal window
git clone https://github.com/strands-labs/strands-decider
cd strands-decider/deploy/lambda
npm install
npx cdk bootstrap aws://<account>/<region>
npx cdk deploy

CDK builds the image in CodeBuild (~10 min) and publishes the function. The Function URL is in cdk deploy’s outputs.

Terminal window
awscurl --service lambda --region <region> -X POST -H 'content-type: application/json' \
-d '{"state": "Help! My payouts have been failing for 3 days!",
"questions": {"is_urgent": {"type": "noul", "instructions": "Does this convey urgency?"}}}' \
<FunctionUrl>v1/systemone
{"model": "strands-decider-2B-qwen3.5-v1-2610-q8_0",
"answers": {"is_urgent": {"type": "noul", "noul": 0.8634}},
"usage": {"input_tokens": 86, "output_tokens": 1},
"latency_ms": 1033.72}

The URL only accepts SigV4-signed requests from principals with lambda:InvokeFunctionUrl. Direct aws lambda invoke works too, with the request as the event payload.

Set in cdk.json, or pass -c key=value to cdk deploy:

SettingDefaultMeaning
modelStrandsAgents/strands-decider-2B-qwen3.5-v1-2610Any Qwen3.5 Decider Hub id; names the stack.
model_revisionmainPin to a release tag (YYMMDD) for reproducibility.
snapstartfalsetrue → ~6 s cold starts instead of up to 30 s; ~$39.50/month for the snapshot cache.
visionfalsetrue adds the base model’s vision tower so requests may carry images.
image_long_side448Longest side an image is scaled to before token-gridding.
decoder_precision / vision_precisionq8_0 / f16f16 / f32 is closer to torch fp32, slower.
max_request_tokens24576Cap on one request’s state-plus-questions tokens.
Terminal window
npx cdk destroy # the default model
npx cdk destroy -c model=<Hub id> # any other deployed model

Removes the function, versions, snapshots, log group, ECR repo, CodeBuild project, and IAM roles.

A separate CDK stack at deploy/lambda-gpu/ serves the same POST /v1/systemone API on a CUDA GPU under Lambda Managed Instances. Same torch + CUDA code path as SageMaker, so the engine sees the model’s full weights and the GPU does the forward pass. The stack defaults to T4 (g4dn) for availability; switch to L4 with -c instance_types=g6.xlarge,g6.2xlarge -c accelerator_memory_gb=24.

  • When to pick it: Low-latency agent-loop guards, per-tool-call checks, and moderate-throughput classifiers behind SQS / EventBridge / direct Invoke. Requires an EC2 GPU vCPU quota; Event Functions only — no Function URL, no synchronous HTTP.
Terminal window
git clone https://github.com/strands-labs/strands-decider
cd strands-decider/deploy/lambda-gpu
npm install
npx cdk bootstrap aws://<account>/<region>
npx cdk deploy

CodeBuild builds the image (~15 min — torch + CUDA layers + model download), publishes to an ECR repository in the stack, and creates the function with a Lambda capacity provider over the configured GPU instance types.

Terminal window
aws lambda invoke --function-name <FunctionArn> --cli-binary-format raw-in-base64-out \
--payload '{"state": "Help! My payouts have been failing for 3 days!",
"questions": {"is_urgent": {"type": "noul", "instructions": "Does this convey urgency?"}}}' \
answer.json
cat answer.json
{"model": "strands-decider-2B-qwen3.5-v1-2610",
"answers": {"is_urgent": {"type": "noul", "noul": 0.86}},
"usage": {"input_tokens": 86, "output_tokens": 1},
"latency_ms": 42.5}

Same JSON works as an SQS message body or an EventBridge event detail.

Terminal window
npx cdk destroy # the default model
npx cdk destroy -c model=<Hub id> # any other deployed model

Removes the function, capacity provider, VPC, ECR repository, CodeBuild project, log groups, and IAM roles. Log groups default to RemovalPolicy.RETAIN; delete them from the CloudWatch console if you want to drop their retained cost.