Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

101 stars

Watchers

5 watching

Forks

Latest commit

 

History

238 Commits

Folders and files

Bedrock AgentCore

Bedrock AgentCore SDK for TypeScript

Deploy AI agents to AWS with VM-level isolation and zero infrastructure

npm version TypeScript Node.js License

Documentation   |   Samples   |   Python SDK


Why AgentCore?

  • 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.

Framework Compatibility

The SDK is designed to work with any agent framework. Here's how:

  • Runtime — Deploy agents built with any framework. The BedrockAgentCoreApp accepts 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.

Quick Start

npm install bedrock-agentcore @strands-agents/sdk
import { 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.


Build Warmup Hook

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.path must equal httpPost.path, and warmupHook.port must equal httpPost.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: 9000 and warmupHook.port: 9000) gets its own listener on 127.0.0.1 in 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 /ping only 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.
  • handlers may only have the keys memory and disk, each a function. Any other key (such as a typo like memroy) or a non-function value throws when the app is constructed. An empty handlers object is fine: every call is answered skipped.
  • 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 as POST /invocations, throws.
  • Serve the hook from one process. The memory call reaches one process, so with several worker processes (for example Node's cluster module) only one of them is warmed.

Tools

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

Features

  • 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)

Installation

npm install bedrock-agentcore

Prerequisites: Node.js 20+, AWS credentials, AgentCore access


Deployment


Resources


License

Apache 2.0 — see LICENSE

Contributing · Security

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

101 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages