Allowing an AI agent to write code is easy; allowing that code to run without endangering credentials, data, or infrastructure is much harder. AWS Lambda MicroVMs address that problem by combining isolated execution environments with durable, stateful orchestration. In a developer preview announced on November 25, 2026, AWS connected Lambda durable functions with launchable MicroVM environments designed for individual tasks, persistent sessions, and coordinated worker groups.
The short answer to whether this can safely run AI-generated code is qualified: MicroVM isolation provides a stronger boundary than an ordinary process or shared container, but it does not make unknown code inherently trustworthy. Safe deployment still requires restrictive networking, narrowly scoped permissions, protected secrets, resource limits, output validation, and reliable cleanup. The preview is nevertheless an important architectural step for AI coding agents, software factories, automated testing, and CI/CD automation.
What AWS introduced in the developer preview
The preview extends serverless computing beyond short, event-driven function invocations. A durable Lambda workflow can launch an isolated virtual machine, assign work to it, pause while an external operation completes, resume from a checkpoint, and terminate the environment when the workflow finishes or fails.
Developers can use these environments in several ways:
- Start a MicroVM for one isolated command, build, test, or code-evaluation task.
- Maintain a persistent session when successive steps need the same files, installed dependencies, or in-memory context.
- Launch multiple workers and coordinate them through a durable parent workflow.
- Track VM creation, task execution, retries, shutdown, and cleanup as part of one recoverable process.
This is different from the Firecracker-based isolation AWS has long used internally for Lambda execution environments. Firecracker is an open-source virtual machine monitor built for secure, lightweight multi-tenant workloads, with technical details available through the official Firecracker project. The preview’s notable change is that applications can incorporate MicroVM lifecycle and task coordination into durable Lambda workflows rather than treating the underlying isolation layer as an invisible implementation detail.
How durable workflows manage MicroVM architecture
Ordinary Lambda functions are intentionally ephemeral. They may reuse an execution environment, but applications cannot depend on a particular environment surviving between invocations. Durable execution changes the programming model by recording workflow progress at defined checkpoints.
Using the AWS Durable Execution SDK, a coordinator can checkpoint important state such as a job identifier, completed build stage, worker assignment, or MicroVM session reference. If the coordinator is interrupted, the workflow can recover from recorded progress instead of restarting the entire operation.
This model supports several operational capabilities:
- Automatic retries: Transient failures can be retried according to workflow policy without repeating already completed durable steps.
- Token refresh: A workflow can obtain or refresh short-lived access tokens before a step that calls another service. Long-lived cloud credentials should never be embedded in generated code or VM images.
- Persistent workspaces: A session can retain files and process state while it remains active, avoiding a full environment rebuild between related tasks.
- Shared files and memory: Processes inside one session can use its local files and memory. Separate MicroVMs should not be assumed to share RAM; cross-worker state belongs in an explicitly supported shared store or messaging layer.
- Lifecycle recovery: The workflow can record whether a VM was requested, started, assigned, stopped, or scheduled for cleanup.
Checkpointing does not preserve every CPU instruction or automatically make arbitrary side effects idempotent. A retried step could still publish a duplicate message, upload the same artifact twice, or repeat an external API call. Applications need idempotency keys, conditional writes, and deduplication where side effects matter.
Why isolated code execution matters for AI agents
AI-generated code execution creates an unusual threat model. The code may contain accidental infinite loops, destructive commands, vulnerable dependencies, or instructions influenced by untrusted prompt content. It could also attempt to inspect environment variables, query instance metadata, scan internal networks, or consume excessive compute.
Cloud sandboxing with a MicroVM can reduce the blast radius because each guest has its own kernel boundary rather than sharing a host kernel with other application containers. That makes AWS Lambda MicroVMs promising for:
- Software factories: Agents can generate, compile, test, package, and evaluate software in disposable environments.
- CI/CD pipelines: Untrusted pull requests or dependency updates can be built without exposing the main runner.
- Automated testing: Each test suite can receive a clean operating environment and controlled network policy.
- Isolated builds: Conflicting compilers, system packages, and toolchains can run in separate sessions.
- Agent sandboxes: Coding assistants can execute commands while a durable controller enforces time, permission, and output limits.
Isolation is only one control. A secure design should treat every generated command and artifact as hostile until validated. The guest should receive no ambient production permissions, and network access should be denied by default or restricted to approved package repositories and APIs.
A practical serverless orchestration architecture
Consider a service that reviews pull requests by asking an AI agent to propose a patch and run the repository’s test suite.
- An Amazon EventBridge rule receives the repository event and sends a normalized job to Amazon SQS.
- An SQS-triggered Lambda validates the request and starts a durable workflow using a unique repository and commit identifier.
- The workflow creates an isolated MicroVM session with defined CPU, memory, storage, time, and network limits.
- A setup worker checks out the exact commit using a short-lived token, installs approved dependencies, and saves the workspace in the session.
- The AI agent writes its proposed changes into that workspace. It does not receive AWS account credentials or direct production access.
- Parallel workers run unit tests, static analysis, dependency checks, and build verification. Results return through controlled task APIs or queues.
- The durable coordinator checkpoints each completed stage. If a worker fails transiently, only that stage is retried.
- Artifacts and structured results are scanned, stored in an approved destination, and published as a status event through EventBridge.
- The workflow revokes temporary tokens, stops the MicroVM, deletes temporary data, and records cleanup completion.
Amazon SQS is useful for buffering work and applying backpressure when MicroVM concurrency is limited. EventBridge provides routing for job-created, build-completed, policy-failed, and cleanup-failed events. Neither service replaces workflow state: the durable coordinator remains responsible for task ordering, checkpoints, retry policy, and lifecycle decisions.
MicroVMs versus containers, Lambda, and dedicated VMs
Containers start quickly and have mature tooling, but containers on the same host normally share a kernel. Hardened runtimes can improve isolation, yet a MicroVM generally provides a clearer kernel boundary for untrusted code.
Conventional Lambda functions already provide managed isolation and excellent event integration. They remain preferable for short, stateless handlers. However, developers cannot rely on local state surviving between invocations or directly manage the underlying environment as a persistent build session. The AWS Lambda Developer Guide remains the authoritative source for standard Lambda behavior and limits.
Dedicated virtual machines offer extensive operating-system control, larger resource choices, and predictable long-running capacity. Their disadvantages include slower provisioning, more infrastructure management, and the risk of idle resources. MicroVM architecture aims for a middle ground: VM-style isolation with lifecycle automation closer to serverless orchestration.
No option is universally safest. Dedicated VMs may still be appropriate for regulated workloads requiring dedicated tenancy or specialized networking. Containers may be sufficient for trusted builds. MicroVMs are especially compelling when code is short-lived, potentially hostile, and coordinated as part of an event-driven workflow.
Security, networking, and permissions
The control plane and guest workload should use separate identities. The durable coordinator may need permission to launch and stop environments, publish events, read queue messages, and write results. The guest should receive only task-specific capabilities, preferably through expiring credentials or brokered APIs.
Do not place secrets in environment images, command lines, generated source files, or persistent logs. Fetch a secret only when required, avoid exposing its raw value to AI context, and revoke it when the task ends. Token refresh should happen through trusted workflow code, not through arbitrary guest logic.
Networking deserves equal attention. Restrict outbound traffic with approved destinations, private endpoints, proxies, DNS policy, or egress filtering where the preview supports them. Block access to account metadata and internal services unless explicitly required. Inbound connections should normally be unnecessary for queue-driven workers.
Cold starts, limits, observability, and cost
MicroVM creation, image preparation, repository checkout, and dependency installation can create a larger cold-start penalty than a small Lambda handler. Persistent sessions can amortize that work across related steps, but keeping sessions alive may increase cost and leave more state to protect. Prebuilt minimal images, dependency caches, bounded session lifetimes, and parallel setup can improve performance.
Preview users must examine quotas for concurrent MicroVMs, workflow duration, vCPU, memory, temporary storage, payload size, network interfaces, and session lifetime. These limits should not be assumed to match conventional Lambda quotas.
Observability should connect the original event, durable workflow, MicroVM session, worker attempt, and output artifact with one correlation identifier. Capture structured logs, lifecycle events, retry counts, execution time, resource exhaustion, and cleanup failures. Guest logs must be filtered so credentials and proprietary source do not leak into monitoring systems.
Cost modeling should include workflow execution, MicroVM runtime, storage, data transfer, queues, events, logs, artifact scanning, and retries. Compare cost per completed job rather than cost per invocation. Because this is a preview, pricing and billing dimensions may change before general availability.
Failure recovery must include cleanup
A durable workflow can recover orchestration state, but it cannot undo every external action. Design each step to be idempotent, place poison jobs in a dead-letter queue, cap retries, and distinguish infrastructure failures from deterministic test failures.
Cleanup should be a durable stage of its own. If the main workflow times out, a compensating process should find orphaned sessions, revoke tokens, preserve permitted diagnostic evidence, and terminate resources. Alarms should detect environments that outlive their expected job window.
Developer preview status and availability
As of November 26, 2026, this integration is a developer preview. AWS does not recommend preview features for production workloads, and preview APIs, behavior, quotas, pricing, and regional coverage can change.
SDK support and regional availability may also depend on preview enrollment, account access, and package version. Before publication or implementation, verify the AWS Durable Execution SDK release notes, the preview documentation, the account’s enabled regions, and the current Lambda console. Do not infer MicroVM availability from standard Lambda regional availability, and do not build a production commitment around an undocumented preview capability.
Can it safely run AI-generated code?
Potentially, yes—when MicroVM isolation is only one layer in a defense-in-depth design. Durable lifecycle control makes it easier to create disposable environments, coordinate workers, retry interrupted stages, and prove that cleanup occurred. The remaining safety controls—minimal permissions, blocked egress, secret brokering, resource ceilings, artifact validation, and human approval for consequential actions—are still the application’s responsibility.
Frequently asked questions
Are AWS Lambda MicroVMs the same as ordinary Lambda execution environments?
No. Standard Lambda already uses managed isolation, but applications normally invoke functions rather than manage an isolated guest session. The preview connects launchable MicroVM tasks and sessions to durable workflow orchestration.
Can a MicroVM make unknown AI-generated code completely safe?
No sandbox offers absolute safety. MicroVMs strengthen isolation, but generated code still needs strict identity, network, secret, storage, time, and resource controls. Outputs should also be scanned before use.
What happens if a worker fails halfway through a build?
The durable workflow can resume from a checkpoint and retry the failed stage according to policy. The application must make external side effects idempotent so a retry does not duplicate releases, messages, or uploads.
Should teams use the preview for production CI/CD?
No. AWS does not recommend developer preview features for production workloads. Teams can evaluate the architecture with non-sensitive repositories and test accounts while retaining a supported production runner.
Use explicit storage, queues, task results, or workflow state. Processes within one persistent session may share local files and memory, but separate MicroVMs should not be treated as if they share RAM or a reliable local filesystem.