Tutorials

How to Run Claude Managed Agents on Amazon Bedrock with TypeScript

Anthropic's new Bedrock SDK brings Claude Managed Agents to Amazon Bedrock. Learn how to create an agent, configure its execution identity, start sessions, and process events using TypeScript.

Calling an AI model and running an autonomous agent are two different operations.

With an ordinary model request, the application sends a message and receives a response. If the model requests a tool, the application may need to execute it, return the result, and initiate another inference request.

As the agent becomes more complex, the application also becomes responsible for maintaining its execution state, managing tools, handling failures, and deciding when the work is finished.

On December 1, 2026, Anthropic released support for Claude Managed Agents on Amazon Bedrock, alongside its preview introduction at AWS re:Invent.

The corresponding TypeScript SDK releases are:

The managed service handles the agent’s execution loop, while AWS provides the infrastructure and identity controls.

However, managed execution does not mean that the developer no longer needs to configure an execution environment or its permissions.

That distinction becomes apparent as soon as we create the first session.

How Claude Managed Agents work on AWS

There are three resources to understand before writing the integration.

Resource Purpose
Agent Defines the model, instructions, tools, and default execution identity
Session Maintains the state and events of a particular interaction
Environment Provides the execution environment for the agent’s tools

An agent can be created once and used across multiple sessions.

For example, an application that analyzes technical documents might use one agent definition while creating a separate session for each document.

The TypeScript application communicates with Bedrock rather than implementing the entire agent loop itself.

flowchart TD
    A["TypeScript application"] --> B["Amazon Bedrock"]
    B --> C["Claude Managed Agent"]
    C --> D["Session"]
    D --> E["Claude model"]
    D --> F["AgentCore Runtime"]
    D --> G["AgentCore Gateway"]
    H["IAM execution identity"] --> D
    D --> I["Session event stream"]
    I --> A

The environment and identity configurations determine where the agent’s tools execute and which AWS resources they can access.

1. Install the Bedrock SDK

Create a small TypeScript project:

mkdir bedrock-managed-agent
cd bedrock-managed-agent

npm init -y
npm install @anthropic-ai/[email protected]
npm install -D typescript tsx @types/node

The Bedrock SDK is the package we need for this example.

Anthropic also released version 1.16.0 of its main SDK, but there is no need to install both packages explicitly unless your application uses both integrations.

Configure TypeScript in tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true
  }
}

The examples below use tsx to execute TypeScript directly.

2. Configure AWS credentials and IAM roles

Before creating an agent, make sure your AWS account has access to the Managed Agents preview in a supported region.

You will also need a compatible execution environment, such as a configured Amazon Bedrock AgentCore Runtime.

The IAM configuration deserves particular attention because three different identities can be involved.

Identity Responsibility
Application identity Authenticates SDK requests and creates or manages agents and sessions
Agent/session execution identity Provides permissions under which the managed session operates
Runtime execution role Controls AWS access from code running inside the AgentCore environment

These roles should not be treated as interchangeable.

For example, granting the agent’s session role permission to read an S3 bucket does not automatically grant the same permission to code executing inside its runtime.

The runtime has its own execution role.

Use the AWS Managed Agents setup documentation to provision the required roles, trust relationships, and environment. Where role passing is required, restrict iam:PassRole to the intended role rather than allowing arbitrary IAM roles.

For local development with an existing AWS IAM Identity Center profile:

aws sso login --profile bedrock-dev
aws sts get-caller-identity --profile bedrock-dev

The second command verifies which AWS identity the CLI is using.

Configure the following environment variables:

AWS_PROFILE=bedrock-dev
AWS_REGION=us-east-1

AWS_AGENT_ROLE_ARN=arn:aws:iam::111122223333:role/ExampleAgentRole

AWS_AGENT_ENVIRONMENT_ID=arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/example-runtime

The account number and resource names are placeholders. Replace them with the resources provisioned in your own AWS account.

An ARN identifies a resource; it does not create that resource or grant permission to access it.

3. Create a Claude agent

Create a file named agent.ts:

import AnthropicBedrock from "@anthropic-ai/bedrock-sdk";

function requireEnv(name: string): string {
  const value = process.env[name];

  if (!value) {
    throw new Error(`Missing environment variable: ${name}`);
  }

  return value;
}

const client = new AnthropicBedrock({
  awsRegion: process.env.AWS_REGION ?? "us-east-1",
  apiKey: null,
});

const executionIdentity = {
  type: "aws_role" as const,
  role_arn: requireEnv("AWS_AGENT_ROLE_ARN"),
};

async function main() {
  const agent = await client.beta.agents.create({
    name: "Technical Assistant",
    model: "global.anthropic.claude-sonnet-5-5",

    execution_identity: executionIdentity,

    system: `
      You are a technical assistant.
      Explain programming concepts using concise examples.
      Do not invent test results or external sources.
    `,
  });

  console.log("Agent ID:", agent.id);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Run the script with the configured environment:

npx tsx --env-file=.env agent.ts

Setting apiKey: null explicitly tells the Bedrock SDK to use AWS credential-based authentication instead of falling back to an Amazon Bedrock bearer token from the environment.

The SDK resolves AWS credentials and signs the requests using Signature Version 4 (SigV4).

There is another detail in the model configuration.

Amazon Bedrock expects an inference profile ID, such as:

global.anthropic.claude-sonnet-5-5

A bare Anthropic model identifier such as claude-sonnet-5-5 is not accepted by this API.

Choose an inference profile supported by your account and region. The geographical prefix also affects where model inference can take place, so global. may not be appropriate for applications with strict regional processing requirements.

4. Create a session and send a task

Creating an agent does not start its work.

The agent is a definition. To execute a particular task, we need a session referencing that definition and an execution environment.

Add the following code inside main(), after creating the agent:

const session = await client.beta.sessions.create({
  agent: agent.id,

  environment_id: requireEnv(
    "AWS_AGENT_ENVIRONMENT_ID"
  ),

  execution_identity: executionIdentity,

  title: "TypeScript explanation",
});

console.log("Session ID:", session.id);

The environment ID identifies the sandbox where the session’s built-in tools can run.

The session also receives an explicit execution identity.

Although the service can use an agent’s default identity under certain conditions, specifying the intended session role directly avoids ambiguity.

We can now send a task through the session’s event API:

await client.beta.sessions.events.send(session.id, {
  events: [
    {
      type: "user.message",
      content: [
        {
          type: "text",
          text: `
            Explain the difference between
            unknown and any in TypeScript.
            Include a short example.
          `,
        },
      ],
    },
  ],
});

Notice that this is not a traditional messages.create() request.

The message becomes an event belonging to an existing session.

The agent processes that event within its managed execution loop.

The SDK also supports supplying initial_events when creating a session. That is useful when the application already knows the first task.

For interactive applications, creating the session first provides more control over when the event stream is established.

5. Receive agent events in real time

Sending a user message does not return the entire generated answer.

Instead, the agent produces events as its work progresses.

For an interactive application, open the event stream before submitting the task.

Replace the previous standalone events.send() call with the following code:

const controller = new AbortController();

const stream = await client.beta.sessions.events.stream(
  session.id,
  {},
  { signal: controller.signal }
);

try {
  const sent = await client.beta.sessions.events.send(
    session.id,
    {
      events: [
        {
          type: "user.message",
          content: [
            {
              type: "text",
              text: "Explain unknown vs any in TypeScript.",
            },
          ],
        },
      ],
    }
  );

  const submittedIds = new Set(
    sent.data.map((event) => event.id)
  );

  let taskObserved = false;

  for await (const event of stream) {
    if (
      event.type === "user.message" &&
      submittedIds.has(event.id)
    ) {
      taskObserved = true;
    }

    if (event.type === "agent.message") {
      for (const block of event.content) {
        if (block.type === "text") {
          console.log(block.text);
        }
      }
    }

    if (
      event.type === "session.status_idle" &&
      taskObserved
    ) {
      console.log("Stop reason:", event.stop_reason);
      break;
    }

    if (event.type === "session.status_terminated") {
      console.log("Session terminated");
      break;
    }

    if (event.type === "session.error") {
      console.error("Session error:", event);
    }
  }
} finally {
  controller.abort();
}

The event stream can contain considerably more than text messages.

Some relevant event types include:

Event Meaning
agent.message A message produced by the agent
agent.tool_use An operation involving an agent tool
agent.mcp_tool_use A request to an MCP-connected tool
session.status_running The session is processing work
session.status_idle The session has paused
session.status_terminated The session has ended
session.error An error occurred during execution

An idle session does not necessarily mean that the task completed successfully.

It might be waiting for input, a tool confirmation, or another action. This is why the example prints stop_reason rather than reporting success unconditionally.

The code demonstrates a single task in a newly created session. A production integration should additionally handle timeouts, reconnection, event deduplication, and concurrent interactions.

What about token-by-token streaming?

The SDK also supports requesting intermediate message deltas:

const stream = await client.beta.sessions.events.stream(
  session.id,
  {
    event_deltas: ["agent.message"],
  }
);

With this option, the connection can receive event_start and event_delta events while the message is being produced.

The final agent.message event contains the completed content.

If your interface displays intermediate deltas, avoid appending the complete message again when the final event arrives. Otherwise, the same response may appear twice.

Intermediate deltas are also best-effort. An interrupted or failed model request may never produce a corresponding completed message.

6. Connect tools through AgentCore Gateway

An agent that only answers questions does not necessarily need access to external systems.

Suppose, however, that the application needs to retrieve information from an internal documentation service.

Amazon Bedrock supports connecting MCP tools through AgentCore Gateway.

When creating the agent, include a gateway configuration:

const agent = await client.beta.agents.create({
  name: "Documentation Assistant",

  model: "global.anthropic.claude-sonnet-5-5",

  execution_identity: executionIdentity,

  system: `
    Answer questions using the connected
    documentation service when necessary.
  `,

  mcp_servers: [
    {
      type: "aws_agentcore_gateway",
      name: "documentation",
      gateway_arn: requireEnv("AWS_GATEWAY_ARN"),
    },
  ],

  tools: [
    {
      type: "mcp_toolset",
      mcp_server_name: "documentation",

      default_config: {
        enabled: false,
      },

      configs: [
        {
          name: "search_documentation",
          enabled: true,
        },
      ],
    },
  ],
});

The example assumes an existing AgentCore Gateway exposing a tool named search_documentation.

There are two separate configurations here.

mcp_servers identifies the gateway, while tools determines which tools from that server the agent may use.

Every configured MCP server must be referenced by an mcp_toolset. Supplying the gateway alone is insufficient and can cause the API to reject the request.

The example also disables tools by default and enables one named operation.

For a documentation assistant, granting access to a search tool makes more sense than exposing unrelated operations that modify or delete data.

The actual AWS permissions still need to enforce that restriction. Tool configuration and system instructions should not be considered substitutes for IAM authorization.

7. Limitations of the December 1 preview

Not every feature available through Anthropic’s own Managed Agents platform is supported in the Bedrock implementation.

One particularly relevant difference concerns built-in web tools.

The Bedrock SDK explicitly documents that:

web_search
web_fetch

are unsupported in its built-in agent toolset.

Including either tool in the configuration can result in a 400 response, even if it is explicitly disabled.

An agent that needs web access must instead use an appropriately configured alternative, such as a supported tool exposed through AgentCore Gateway.

Other capabilities may depend on preview access or additional account configuration.

For example, attaching S3 resources to a session requires compatible runtime infrastructure and account-level support.

The service also distinguishes between the IAM identity of a managed session and the identity under which sandbox code accesses S3.

Changing permissions on one role will not necessarily resolve an access error originating from the other.

Monitor execution and costs

AWS integrates managed agent operations with IAM, CloudTrail, and CloudWatch.

This allows developers to investigate API activity, review access, and monitor their deployments using AWS tooling.

However, the exact information available in logs depends on the configured services and logging settings.

There is also a cost difference between a single model request and a managed session.

An agent can perform multiple inference calls while working toward one result. It may also use runtime resources, external tools, or storage.

Even when the managed orchestration layer has no separate preview charge, these underlying resources can still generate costs.

The SDK defines an optional session budget:

budget: {
  type: "limit",
  max_list_cost: {
    amount: "1.00",
    currency: "USD",
  },
}

This can be included when creating a session if the selected backend supports it.

The SDK warns that an unsupported budget field can cause session creation to fail. Removing it would create a session without that spending ceiling.

It should also not be interpreted as a universal limit on every separate AWS infrastructure charge.

Configure AWS Budgets and monitor the resources used by the execution environment as well.

When a test session is no longer needed, the SDK exposes a deletion operation:

await client.beta.sessions.delete(session.id);

Deleting the session does not imply that separately provisioned AgentCore infrastructure, gateways, or S3 resources have also been deleted. Those resources have their own lifecycles.

What changes for TypeScript developers?

The December 1 release provides another way to integrate Claude agents into applications already deployed on AWS.

Instead of manually implementing the complete interaction between the model, tools, and execution state, the application can work with agent definitions, sessions, and events.

The TypeScript integration itself is relatively small.

But the infrastructure around it still requires attention.

The execution environment must exist. IAM roles must have appropriate permissions. External tools must be explicitly connected, and the application needs to understand why a session has stopped.

For applications already using AWS identity management and observability, these responsibilities fit into an existing infrastructure model.

The managed service removes part of the orchestration work without removing the need to control what the agent is permitted to do.

As of December 1, 2026, Claude Managed Agents for Amazon Bedrock remains a preview feature. Its availability, API contracts, and supported capabilities may change before general availability.

External Sources used for this article

Related Articles

View all →