- Zero infrastructure — No servers to provision, no containers to manage, no scaling to configure.
- Session isolation — Each agent session runs in its own VM. No shared state, no noisy neighbors.
- Long-lived sessions — Sessions persist across requests. Your agent maintains context without external storage.
- Managed tools — Secure code execution and browser automation, ready to use.
- Credential management — Centralized API keys and OAuth tokens, injected at runtime.
The SDK is designed to work with any agent framework. Here's how:
- Runtime — Deploy agents built with any framework. The
BedrockAgentCoreAppaccepts any request handler — plug in Strands Agents, Vercel AI SDK, LangChain, or your own custom logic. - Tools — Code Interpreter and Browser tools include built-in integrations for Strands Agents and Vercel AI SDK, so tools can be passed directly to those frameworks' agents. For other frameworks, use the core clients (
CodeInterpreter,PlaywrightBrowser) directly and wire them into your own tool definitions. - Identity — Credential wrappers (
withAccessToken,withApiKey) work with any async function, regardless of framework.
npm install bedrock-agentcore @strands-agents/sdkimport { BedrockAgentCoreApp } from 'bedrock-agentcore/runtime'
import { Agent, BedrockModel } from '@strands-agents/sdk'
import { z } from 'zod'
const agent = new Agent({
model: new BedrockModel({ modelId: 'global.amazon.nova-2-lite-v1:0' }),
})
const app = new BedrockAgentCoreApp({
invocationHandler: {
requestSchema: z.object({ prompt: z.string() }),
process: async function* (request) {
for await (const event of agent.stream(request.prompt)) {
if (event.type === 'modelContentBlockDeltaEvent' && event.delta?.type === 'textDelta') {
yield { event: 'message', data: { text: event.delta.text } }
}
}
},
},
})
app.run()Use requestSchema to validate agent entrypoint input. Keep user prompts typed as strings and pass only prompt text
to the agent framework.
BedrockAgentCoreApp creates an AgentCore Runtime-compliant server—handling request parsing, streaming responses, and session management for seamless deployment.
Building multi-agent systems? Host agents on AgentCore's A2A protocol path with serveA2A — see the runtime guide.
On platform version V2, AgentCore Runtime can call a build warmup hook while it prepares your agent, before the runtime is READY. It sends two POST requests, first memory (load what every session needs, such as imports, models and caches) and then disk (read the files that sessions read at start). Set warmupHook with a handler for either, both or none:
import { readFile } from 'fs/promises'
import { BedrockAgentCoreApp } from 'bedrock-agentcore/runtime'
let model: Model | undefined
const app = new BedrockAgentCoreApp({
invocationHandler: {
process: async (request) => model!.predict(request),
},
warmupHook: {
path: '/warmup', // serves the hook at POST /warmup
handlers: {
memory: async () => {
model = await loadModel() // runs before the runtime is READY; sessions start with what's loaded here
},
disk: async () => {
for (const file of ['/app/config/agent.json']) {
await readFile(file)
}
},
},
},
})
app.run()The hook responds 200 after the handler resolves; a type without a handler, or a type the SDK doesn't know, also gets 200 (skipped). Only a missing or empty warmup type header gets 400. A rejected handler returns 500, which fails the create or update. The two calls share a 120-second limit. Configure the hook on the runtime:
await client.send(
new CreateAgentRuntimeCommand({
// other runtime settings
platformVersion: 'V2',
hooksConfiguration: { build: { warmup: { action: { httpPost: { path: '/warmup' } } } } },
})
)warmupHook.pathmust equalhttpPost.path, andwarmupHook.portmust equalhttpPost.port. Omit both ports to serve the hook on the app's serving port (app.run({ port }), default 8080).- A hook on another port (for example
httpPost.port: 9000andwarmupHook.port: 9000) gets its own listener on127.0.0.1in the same process.app.run()starts it before the serving port. - Handlers must be async and must not block the event loop: the server answers
/pingonly while a handler awaits. Run CPU-heavy work in a worker thread or child process. Generator functions are rejected when the app is constructed, because their body would never run. handlersmay only have the keysmemoryanddisk, each a function. Any other key (such as a typo likememroy) or a non-function value throws when the app is constructed. An emptyhandlersobject is fine: every call is answeredskipped.- The path (1–32 characters from
A-Z a-z 0-9 . _ ~ / -, starting with/, in canonical form) and the port (8000–12000) are validated when the app is constructed. A hook route that's already served on its port, such asPOST /invocations, throws. - Serve the hook from one process. The memory call reaches one process, so with several worker processes (for example Node's
clustermodule) only one of them is warmed.
Give your agent secure code execution with three lines:
import { CodeInterpreterTools } from 'bedrock-agentcore/experimental/code-interpreter/strands'
import { Agent, BedrockModel } from '@strands-agents/sdk'
const codeInterpreter = new CodeInterpreterTools({ region: 'us-east-1' })
const agent = new Agent({
model: new BedrockModel({ modelId: 'global.amazon.nova-2-lite-v1:0' }),
tools: codeInterpreter.tools,
})
// Agent can now execute code in a secure sandboxed environment- Runtime — Secure, session-isolated compute → Examples
- A2A — Agent-to-agent communication on the A2A protocol path → Guide
- Code Interpreter — Execute Python/JS/TS in a sandbox → Examples
- Browser — Cloud-based web automation → Examples
- Web Search — Search the web through a Gateway connector target → Guide
- Identity — Manage API keys and OAuth tokens → Examples
- Memory — Persistent knowledge across sessions → Guide
- Gateway — Transform APIs into MCP tools (coming soon)
- Observability — OpenTelemetry tracing (coming soon)
npm install bedrock-agentcorePrerequisites: Node.js 20+, AWS credentials, AgentCore access
- Sample Applications — Working examples with deployment templates
- CloudFormation — Infrastructure as code
- AWS CDK — Infrastructure as code
- Deployment Guide — Step-by-step walkthrough
Apache 2.0 — see LICENSE