awslabs / awslabs/agentcore-samples
RFC: Add pattern 3 (agent in Lambda MicroVM) to agents-on-aws-lambda
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 1.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 30
Description
### Motivation
`03-integrations/agents-hosted-outside-runtime/agents-on-aws-lambda/` currently has two patterns:
- `01-lambda-invokes-runtime/` — Lambda function invokes an AgentCore runtime
- `02-agent-in-lambda/` — Strands agent wrapped in a Lambda function (managed ADOT Lambda Layer)
Neither covers agents running inside **Lambda MicroVMs** — the Firecracker-based compute primitive that Claude Managed Agents and Cursor Cloud Agents use as their sandbox today. The managed ADOT Lambda Layer used in Pattern 1 targets the Lambda function execution environment and does not apply to MicroVMs, so the OTLP wiring for AgentCore Observability is genuinely different: the ADOT SDK is installed into the container image, and the OTEL configuration is baked into the MicroVM snapshot at image build time.
### What I'd add
A `03-agent-in-lambda-microvm/` folder that mirrors the file layout of the two existing patterns:
```
03-agent-in-lambda-microvm/
├── README.md # What MicroVMs bring / Architecture / Files / Prereqs /
│ # Quick Start / How observability works / Viewing traces /
│ # Troubleshooting / Additional Resources
├── deploy.py # end-to-end idempotent deploy
├── invoke.py # launch MicroVM, mint auth token, POST test prompts
├── cleanup.py # idempotent teardown
├── config.py # constants + OTEL env-var builder (AgentCore contract)
├── requirements.txt # boto3 >= 1.43.72 (client side)
└── app/
├── Dockerfile # al2023-minimal ARM64 + Python 3.11 + ADOT
├── agent.py # Strands agent + http.server on :8080
├── entrypoint.sh # opentelemetry-instrument wrapper
└── requirements.txt # aws-opentelemetry-distro, strands-agents[otel], boto3
```
Plus a small update to the parent `agents-on-aws-lambda/README.md` — adds a third row to the "Patterns at a glance" table and a matching "Pattern 3" section so the new folder is discoverable. Style matches the existing entries (a paragraph on what the pattern is, a "Best for:" line, and a link).
### Preview branch (ready to review)
- Sample folder: https://github.com/vipulg1993/agentcore-samples/tree/feat/add-lambda-microvm-agentcore-observability-sample/03-integrations/agents-hosted-outside-runtime/agents-on-aws-lambda/03-agent-in-lambda-microvm
- Full compare vs upstream `main`: https://github.com/awslabs/agentcore-samples/compare/main...vipulg1993:agentcore-samples:feat/add-lambda-microvm-agentcore-observability-sample
### Tested end-to-end
- `deploy.py` → `create_microvm_image` → CREATED in ~135s (ARM64, 2 GB baseline).
- `invoke.py` → 3 prompts through the per-VM HTTPS endpoint, HTTP 200 each.
- CloudWatch Logs Insights confirms 5 nested OTLP spans per invoke land in `/aws/bedrock-agentcore/runtimes/` with `session.id`, `aws.lambda.microvm.image_name`, and `aws.lambda.microvm.image_version` propagated.
- `cleanup.py` tears everything down cleanly.
### Questions for maintainers
1. Is `03-integrations/agents-hosted-outside-runtime/agents-on-aws-lambda/` the right home, or would `features/observability/` be a better fit?
2. Any concerns with the pattern name `03-agent-in-lambda-microvm` (I followed the existing folder-numbering convention)?
3. Anyone from the AgentCore Observability or Lambda MicroVMs team you'd like me to loop in before I open the PR?
Happy to open the PR once you give the go-ahead — the branch is ready.
Contributor guide
Research direction
Compare 01-lambda-invokes-runtime/ and 02-agent-in-lambda/ under 03-integrations/agents-hosted-outside-runtime/agents-on-aws-lambda/, then review the preview branch linked in the issue. The work is done when the new 03-agent-in-lambda-microvm/ files and the parent README updates are present, and the deploy, invoke, cleanup, and observability flow can be validated end to end.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, python
- Domain
- cloud, observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100