feat(agents-on-aws-lambda): add pattern 3 for agent in Lambda MicroVM with AgentCore Observability - #2076
Merged
rajeshkumarravi merged 5 commits intoSep 14, 2026
Conversation
added 3 commits
September 11, 2026 14:16
…ability
Adds a third pattern under agents-on-aws-lambda that hosts a Strands
agent inside a Lambda MicroVM and exports OTLP telemetry (traces,
spans, logs, token metrics) to Amazon CloudWatch via the AWS Distro
for OpenTelemetry (ADOT) Python SDK.
Motivation
----------
- Pattern 1 (01-lambda-invokes-runtime) covers Lambda -> AgentCore runtime
- Pattern 2 (02-agent-in-lambda) covers a Strands agent wrapped in a
Lambda function using the managed ADOT Lambda Layer
- Neither covers Lambda MicroVMs, the compute primitive Claude Managed
Agents and Cursor Cloud Agents use today. The ADOT wiring is
materially different: the managed Lambda Layer does not apply to
MicroVMs, so this sample installs the ADOT SDK into the container
image and bakes the AgentCore Observability env-var contract into
the MicroVM snapshot at image build time.
What is added
-------------
03-integrations/agents-hosted-outside-runtime/agents-on-aws-lambda/
03-agent-in-lambda-microvm/
README.md awslabs-style: Architecture, Files, Prereqs,
Quick Start, How observability works, Viewing
traces, Additional Resources
deploy.py 9-step idempotent deploy: Transaction Search,
log group + resource policy, S3 bucket, IAM
roles, package + upload, create_microvm_image
invoke.py Launch a MicroVM, mint an auth token, POST
test prompts, print CloudWatch verify links
cleanup.py Idempotent teardown
config.py Shared constants + otel_env() builder
requirements.txt boto3 >= 1.43.72 (client side)
app/
Dockerfile al2023-minimal ARM64 + Python 3.11 + ADOT
agent.py Strands + Bedrock + http.server on :8080
entrypoint.sh opentelemetry-instrument wrapper
requirements.txt aws-opentelemetry-distro>=0.18.0,
strands-agents[otel], boto3
.dockerignore
Tested end-to-end
-----------------
- deploy.py -> image CREATED in ~135s (ARM64, 2 GB baseline)
- invoke.py -> 3 prompts, HTTP 200 each
- CloudWatch Logs Insights confirms 5 nested OTLP spans per invoke
land in /aws/bedrock-agentcore/runtimes/<agent-id> with session.id,
aws.lambda.microvm.image_name, and aws.lambda.microvm.image_version
propagated
- cleanup.py -> tears everything down cleanly
Rebalance the README so it introduces the sample on its own terms
rather than positioning it against patterns 1 and 2.
- Replace the "Why this is not just Pattern 2 with a different host"
section with a short "What MicroVMs bring to agent observability"
paragraph focused on what the primitive actually offers (long-lived
process, snapshot resume, per-VM identity attributes).
- Move the "ADOT SDK vs ADOT Collector" note up into the "How
observability works" section as the leading subsection ("Why the
ADOT SDK"), so the transport choice is explained as design context
rather than a lesson learned.
- Move the operational quirks (build-role credential caching, reserved
env vars, log-stream pre-creation, ready-hook toggle, missing spans)
into a Troubleshooting section framed as symptom / cause / fix, so a
reader hits them only if they encounter them.
Add the third row to the "Patterns at a glance" table and a matching "Pattern 3 — Agent in Lambda MicroVM" section so the new pattern is discoverable from the folder root. Style matches the existing entries.
|
Latest scan for commit: Security Scan Results |
added 2 commits
September 11, 2026 16:40
Address the 13 findings reported by `python-lint` on the initial PR: - Remove unused `# noqa` directives (RUF100) — the ruff config for this repo doesn't enable BLE001, E402, or S310, so the suppressions were redundant. - Sort imports in cleanup.py, deploy.py, invoke.py (I001). - Rewrite `dict(...)` call to a dict literal in deploy.py (C408). - Drop the extraneous `f` prefix on 4 f-strings that had no placeholders (F541). All fixes are purely stylistic; runtime behaviour is unchanged. Verified with `ruff check` (clean) and `python3 -m py_compile` (all pass).
The python-lint workflow runs two checks: `ruff check` (fixed in the previous commit) and `ruff format --check`. Applying `ruff format` to match the repo's formatter output — joined split f-strings that fit on a single line, single-space around operators, and the standard two blank lines between top-level function definitions. No behavioural changes. Verified locally with both `ruff check` and `ruff format --check` clean.
rajeshkumarravi
approved these changes
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2075.
What this PR adds
A new
03-agent-in-lambda-microvm/folder underagents-on-aws-lambda/that hosts a Strands agent inside a Lambda MicroVM and exports OTLP telemetry (traces, spans, structured logs, token metrics) to AgentCore Observability via the ADOT Python SDK. Full motivation and design in the RFC.File layout mirrors the two existing patterns:
Also updated
agents-on-aws-lambda/README.mdadds 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 two existing entries.Tested end-to-end
python deploy.py→create_microvm_imagereachesCREATEDin ~135 s (ARM64, 2 GB baseline)python invoke.py→ 3 prompts through the per-VM HTTPS endpoint, HTTP 200 each/aws/bedrock-agentcore/runtimes/<agent-id>withsession.id,aws.lambda.microvm.image_name, andaws.lambda.microvm.image_versionpropagatedpython cleanup.pytears everything down (MicroVMs, image, IAM roles, S3 bucket) idempotentlyChecklist
CONTRIBUTING.mdmainpython3 -m py_compilepasses on every.pyfileCreateMicrovmImagepayload validates against the boto3 service model