Clean up resources
When you finish with Claude Managed Agents for Amazon Bedrock, delete sessions before you delete what they use, and copy any files you want to keep first.
Save files and events
Copy files and export any session events you want to keep before you delete a session. On AgentCore, files in the container's own file system go away when the session's container stops. Files the agent wrote to an S3 folder, a repository, or another system stay there. Delete them separately when you no longer need them.
To keep the conversation in the service, archive the idle session instead of deleting it. Archiving keeps the events, not the container's files. For a session without S3 folders or files, its AgentCore container can remain until the runtime's idle timeout. For a session with S3 folders or files, archiving asks AgentCore to stop the container right away.
Delete your sessions
List the sessions your role created, and delete each one you no longer need:
cma GET "sessions?created_by_me=true" | jq -r '.data[] | [.id, .status, (.title // "")] | @tsv' cma DELETE "sessions/sesn_..."
The list returns one page. If the answer has next_page, repeat the request with &page= and that value.
The cma shell function is in Step 1: Set up a shell of Run your first agent. A running session cannot be deleted, so send it a user.interrupt first. Deleting a session deletes its events and stops its container on AgentCore. Self-hosted, stop the tool runner yourself. To keep a session's events, archive it with POST /sessions/{id}/archive instead. Delete only sessions that belong to your application.
Delete memory stores
Delete the memory stores you no longer need, which deletes their memories and versions. To keep one read-only instead, archive it:
cma DELETE "memory_stores/memstore_..." cma POST "memory_stores/memstore_.../archive"
Archive your agents
Agents cannot be deleted. Archive the ones you no longer use, so no new session starts on them:
cma POST "agents/agent_.../archive"
Delete the stack
If you used the CloudFormation template, first detach the ClaudeManagedAgentsCaller policy from CmaCaller, or delete CmaCaller, if you created it. CloudFormation can't delete a managed policy that is still attached to a role. Then delete the stack:
IMAGES=$(aws ecr list-images --region us-west-2 --repository-name cma-tool-runner \ --query imageIds --output json) if [ "${IMAGES}" != "[]" ]; then aws ecr batch-delete-image --region us-west-2 --repository-name cma-tool-runner \ --image-ids "${IMAGES}" fi aws cloudformation delete-stack --region us-west-2 --stack-name claude-managed-agents aws cloudformation wait stack-delete-complete --region us-west-2 --stack-name claude-managed-agents
CloudFormation cannot delete a repository that still holds images, which is why the images go first. Deleting the stack removes the runtime, the repository, the roles, and the caller policy.
Every application that uses the caller policy loses access, and every session that uses the session role stops working.
If you made the resources in the console, delete them in this order: the AgentCore Runtime, the ECR repository, the caller policy, the tool runner role, and the session role.
Check what is left
Log groups. The runtime's log groups under
/aws/bedrock-agentcore/runtimes/stay after the runtime is deleted. Delete them, or set a retention period.Data retention mode. If you set
aws_reviewfor Claude Fable, it still applies to every Amazon Bedrock call in the account. Set it back if nothing else needs it.Self-hosted. Delete the session folders and
activation.jsonfiles you made, thecma-runnerprofile, andCmaSelfHostedToolRunnerRoleif you created it by hand.Caller role. Delete
CmaCallerand thecma-callerprofile if you created them.Customer managed keys. If you set a project's encryption configuration, delete
CmaKeyRoleand schedule the AWS KMS key for deletion only after you delete the project's sessions and memory stores. Once AWS KMS deletes the key, content under it can't be recovered.Examples. Each example has its own stack and its own clean-up steps. See Clean up the examples.