Runtime Instances: Persistent Compute for AI Agents on Amazon Bedrock
In the world of AI, managing workloads efficiently is crucial. Runtime instances in Amazon Bedrock AgentCore provide a solution by offering persistent, managed infrastructure tailored for complex agent workloads. This means your AI agents can operate seamlessly without the overhead of constantly spinning up new environments, allowing for faster and more reliable processing.
At the core of this functionality are microVMs, which create a fully managed environment for invocations. These microVMs can run for up to 8 hours and support stateful workflows through managed session storage. The orchestrator agent on the runtime microVM coordinates tasks, routing them to specialized worker agents that perform compute-intensive operations, such as code compilation or security scanning. You can configure these instances with specific parameters, like the operating system (default is Linux 64-bit ARM), allowed EC2 instance types (default is c7g.2xlarge), and the programming language runtime (default is Python 3.13). This flexibility helps you tailor the environment to your specific needs.
In production, it’s essential to understand how session persistence works. Sessions can last up to 14 days, which is beneficial for long-running tasks. However, keep in mind that while these microVMs are powerful, they may not be suitable for every scenario. Always evaluate your workload requirements and test thoroughly to ensure optimal performance.
Key takeaways
- →Leverage Runtime instances for persistent compute in AI workflows.
- →Utilize microVMs for stateful workflows with managed session storage.
- →Configure parameters like operating system and instance types to fit your needs.
- →Understand session persistence of up to 14 days for long-running tasks.
Why it matters
In production, efficient resource management can significantly reduce costs and improve response times for AI agents. Runtime instances streamline operations, allowing teams to focus on development rather than infrastructure management.
Code examples
1writer = Agent(
2 model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
3 system_prompt=(
4 "You are a senior Python engineer. "
5 "Given a task, return ONLY a single Python code block — no prose."
6 ),
7)
8
9@app.entrypoint
10def handler(event, context):
11 task = event.get("task") or event.get("prompt")
12 session_id = getattr(context, "session_id", None) or event.get("session_id")
13 session_dir = SHARED_DIR / session_id
14 session_dir.mkdir(parents=True, exist_ok=True)
15
16 code = str(writer(task))
17 (session_dir / "code.py").write_text(code)
18
19 return {"agent": "writer", "wrote": str(session_dir / "code.py"), "code": code}1reviewer = Agent(
2 model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
3 system_prompt=(
4 "You are a strict Python code reviewer. "
5 "Given code, return 3 bullet points: bugs, style, suggestions."
6 ),
7)
8
9@app.entrypoint
10def handler(event, context):
11 session_id = getattr(context, "session_id", None) or event.get("session_id")
12 code_path = SHARED_DIR / session_id / "code.py"
13 code = code_path.read_text()
14 review = str(reviewer(f"Review this code:\n\n{code}"))
15
16 return {"agent": "reviewer", "read": str(code_path), "review": review}When NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsSimple, affordable cloud — VMs, Kubernetes, and managed databases in minutes. Trusted by 600,000+ developers. Spin up a Droplet in 60 seconds.
Try DigitalOcean →AWS Price Cuts and New Monitoring Tools: What You Need to Know
AWS has slashed prices for GPT models in Bedrock, making advanced AI more accessible. With an 80% reduction in on-demand inference prices for GPT-5.6 Luna, it's a game changer for developers. Plus, CloudWatch now offers managed collectors for Prometheus metrics, simplifying your monitoring strategy.
Unlocking AWS Innovations: Claude Sonnet 5 and Enhanced WorkSpaces for AI
AWS is rolling out powerful updates that can transform your cloud strategy. With Claude Sonnet 5 now available and Amazon WorkSpaces enabling AI agents to operate seamlessly, you’ll want to dive into these features. Discover how these tools can enhance your productivity and efficiency.
Designing AI-Powered Customer Experiences with Amazon Connect
Amazon Connect now allows business teams to create AI-driven customer experiences without writing a single line of code. The new Agentic CX designer offers a no-code canvas that transforms how customer interactions are built and managed.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.