Claude Managed Agents examples
The examples are in claude-managed-agents-examples.zip. Each one has its own README and clean-up steps, and most have a CloudFormation template. memory and evaluation have none. Run them in a development account: they create IAM roles, AgentCore Runtimes, and data stores, and some create billable networking.
Example | What it shows | Guide topic |
|---|---|---|
| Running an agent on a schedule with Amazon EventBridge Scheduler and AWS Lambda. | |
| An agent that changes private GitHub repositories and opens pull requests, with one-hour tokens from your own GitHub App. | |
| An accounts payable agent that matches a month of invoices in Amazon S3 to purchase orders in Amazon DynamoDB, and approves or flags each one through custom tools. | |
| An on-call agent that finds the cause of an outage in two hours of service logs, writes the postmortem, and answers follow-up questions in the same session. | |
| Six support tickets handled in parallel sessions with MCP tools from an AgentCore Gateway, where each refund waits for a supervisor's approval. | |
| A coordinator agent that hands eight vendor contracts to two other agents, one to read the terms and one to check them against a playbook. | |
| An agent that searches the web with the managed Web Search Tool behind an AgentCore Gateway. | |
| A tool runner in a VPC with no internet access, connected to the service through an interface endpoint for Amazon Bedrock. | |
| What a session keeps when AgentCore replaces its container, with AgentCore session storage and without it. | |
| Notes and skills kept in Amazon S3 and mounted with Amazon S3 Files, so they outlast every session and change without a new image. | |
| Memory stores read and written by agents with the memory tools and by your code through the API, and checked against each other. | |
| An Amazon Bedrock guardrail enforced on every model call in the account, and what a session shows when it blocks a message or a reply. | |
| A session you have already run, scored with the evaluators of Amazon Bedrock AgentCore Evaluations. |
Get the examples
Download claude-managed-agents-examples.zip and claude-managed-agents-tool-runner.zip, and unzip the examples in the same folder as the tool runner bundle:
unzip claude-managed-agents-examples.zip cd examples
The examples need the tool runner binary, which is in the tool runner bundle, not in the examples zip. Most examples take the path to cma-tool-runner-linux-arm64 from the bundle's bin/. memory and account-guardrail don't need it.
Before you start
Every example needs the following. The table after it lists what each example needs on top of that.
Your account is set up as in Set up permissions and prerequisites, so the session role
ClaudeManagedAgentsSessionRoleexists. Most examples' stacks add an inline policy to that role so it can invoke the example's runtime. To use a different session role, pass the stack'sSessionRoleNameparameter. Thescheduled-agentstack doesn't take one. Onlygithub-repo-agent/run.pyalso takes--session-role-arn; the other examples always useClaudeManagedAgentsSessionRole.A profile for a role with the
ClaudeManagedAgentsCallerpolicy, such ascma-callerfrom Create a role to call as, for therun.pyscripts. The API refuses IAM users, so use a role profile, such as an SSO profile or one withrole_arn.If you run
run.pyas a different role thansetup.sh, such as one with onlyClaudeManagedAgentsCaller, that role also needs to read what the scenario's stack made:cloudformation:DescribeStackson the stack, ands3:GetObject,dynamodb:Scan, anddynamodb:Queryon the scenario's bucket and tables.run.pyreads the stack's outputs and then checks the agent's work in them.account-guardrailalso needsbedrock:ListGuardrailsandbedrock:ListEnforcedGuardrailsConfiguration.A deployment identity for
setup.shand the CloudFormation commands. The example stacks create IAM roles and inline policies, ECR repositories and images, AgentCore Runtimes and Gateways, Lambda functions, and data stores, so this identity needs broad permissions such asiam:CreateRole,iam:PutRolePolicy, andiam:PassRole. Those are for setting up the examples only. The role your agents call the API with needs none of them.Access to the Claude models the examples use in Amazon Bedrock:
us.anthropic.claude-sonnet-5-5by default for every example. To use another model ID, such aseu.anthropic.claude-sonnet-5-5in the EU Regions, pass--modelto the example's script.evaluation/run.pydoesn't take it, andscheduled-agenthas no script to run. Claude model names, such asclaude-sonnet-5-5, are refused.Docker with
buildx, running. The images are built for ARM64 without emulation, so an x86-64 machine works.AWS CLI version 2, and Python 3.10 or newer with boto3 and pip. The image build downloads Python packages from PyPI, so the machine needs access to it.
sha256sumon yourPATH. Recent macOS versions include it. On an older Mac, install GNU coreutils.All stacks in the same Region as your API endpoint. The commands below use US West (Oregon).
export AWS_PROFILE=my-deployment-profile # for setup.sh and stacks; use cma-caller for run.py export AWS_REGION=us-west-2 export CMA_ENDPOINT_URL=https://bedrock.us-west-2.amazonaws.com/anthropic/v1 RUNNER=<bundle>/bin/cma-tool-runner-linux-arm64
Replace with the path to the folder where you unzipped the tool runner bundle.bundle
Example | Also needs | Time and cost notes |
|---|---|---|
| An agent and an AgentCore Runtime you already have, such as the ones from Run your first agent. | Each scheduled run leaves an idle session. Delete them, or the stack, when you finish. |
| A GitHub App you can register in the organization that owns the repositories, and install on them. That usually takes an organization owner. | The App's private key is in AWS Secrets Manager, and the agent gets one-hour tokens through a Lambda function. The model can read a token while it is valid. |
Four scenarios | Nothing more. They share one image, built the first time you run a scenario's | About 5 to 10 minutes each, 25 minutes for all four, with setup. |
| The AgentCore Gateway Web Search Tool in your Region. | Under a minute per run. |
| Permission to create a VPC, interface endpoints, and an AgentCore Runtime in VPC network mode. | Each interface endpoint is billed for every hour it exists, in each of the two subnets. Delete the stack when you finish. |
| AgentCore Runtime session storage in your Region. | About 10 minutes, most of it waiting for AgentCore to replace the container. |
| Amazon S3 Files in your Region, and permission to create a VPC, a NAT gateway, and the | About 10 minutes to create. The NAT gateway is billed by the hour, so run cleanup.py when you finish. |
| Nothing more. Its sessions use the project's self-hosted environment, so no runtime is started. | About three minutes. |
| Permission to create an Amazon Bedrock guardrail and an enforced guardrail configuration. | The guardrail applies to every model call in the account and Region, from every role, while the stack exists. Use a test account, and delete the stack when you finish. |
| A session you have already run, permission to call AgentCore's Evaluate API, and a boto3 version with the | Nothing to deploy. Each run sends one session's spans to the Evaluate API. |
Run a scenario
The four scenarios are tasks a team might hand an agent, with mock data that has known right answers. Each one's run.py runs the task and then checks what the agent did, so a run ends with a list of passed and failed checks.
Feature | invoice-reconciliation | incident-investigation | support-desk | contract-review |
|---|---|---|---|---|
AWS resources | S3, DynamoDB | S3, DynamoDB | DynamoDB, Lambda, AgentCore Gateway | S3, DynamoDB |
Sessions | 1 | 1, with 3 turns | 6, at the same time | 1, with 3 agents |
Custom tools | Yes | No | No | No |
MCP tools | No | No | Yes | No |
Tool confirmations | No | No | Allow and deny | No |
Skills | Yes | Yes | Yes | Yes |
Coordinator and called agents | No | No | No | Yes |
What the tools can reach | Read the data, write one report | Read the logs, write under | Nothing. The data is reachable only through the gateway's tools. | Read the contracts, write the reviews and the memo |
cd invoice-reconciliation ./setup.sh "$RUNNER" python3 run.py
setup.sh builds and pushes the shared image if it needs to, deploys the scenario's stack, and loads its mock data. Run it again to reset the data. For support-desk, run python3 data.py before a later run to clear the last run's refunds and notes. The image holds every scenario's skills, so after you change a skill, run that scenario's setup.sh again.
A check can fail because the model made a wrong call, not because anything is broken. The checks say what was expected and what the agent did, and run.py keeps the session of a failed run so you can read its events. To run all four:
for s in invoice-reconciliation incident-investigation support-desk contract-review; do (cd "$s" && ./setup.sh "$RUNNER" && python3 run.py) || echo "$s failed" done
What the scenarios share
File | What it is |
|---|---|
| One tool runner image for all the scenarios, with Python 3.12, boto3, and the AWS CLI, and each scenario's |
| The |
| A small Python client for the API. It signs requests, reuses agents, streams a turn's events, answers custom tool calls and tool confirmations, and records the checks. You can reuse it in your own code. |
Run the other examples
Example | Steps (see its README for details) |
|---|---|
| Find your agent ID and runtime ARN, deploy |
| Register a GitHub App and install it on the repositories, deploy the stack, put the App's private key in its secret, build the image with |
|
|
|
|
|
|
|
|
|
|
| Deploy |
|
|
Clean up the examples
Each example's README has its own steps. To remove the four scenarios and their shared image repository:
for s in invoice-reconciliation incident-investigation contract-review; do bucket=$(aws cloudformation describe-stacks --stack-name "$s" \ --query "Stacks[0].Outputs[?OutputKey=='Bucket'].OutputValue" --output text) aws s3 rm "s3://$bucket" --recursive done for s in invoice-reconciliation incident-investigation support-desk contract-review cma-scenarios-image; do aws cloudformation delete-stack --stack-name "$s" done
The privatelink and s3-files examples create resources that are charged while they exist: interface endpoints, and a NAT gateway. Remove them when you finish:
aws cloudformation delete-stack --stack-name privatelink (cd s3-files && python3 cleanup.py)
Deleting a stack removes the inline policy it added to the session role. The agents the examples create stay in your project. Archive them with POST /agents/{id}/archive if you no longer want them listed.