AWS Builder Center

Runtime Circuit Breakers for AI Agent Tools with AWS AppConfig and Amazon Bedrock AgentCore

Learn how to dynamically enable or disable individual AI agent tools in production without agent redeployment.

ο»Ώ

Your team has deployed an AI agent to production. A tool starts misbehaving, and the agent keeps calling it β€” burning LLM tokens, frustrating users, and compounding the incident. You need to disable that one tool right now, without redeploying the agent.
Runtime circuit breakers solve this by letting you disable individual agent tools instantly, without agent redeployment . This post walks you through implementing runtime circuit breakers for AI agent tools using Β AWS AppConfigΒ  and Β Amazon Bedrock AgentCoreΒ . For demo purposes, we built a Telecom Billing Assistant Agent with Strands Agents SDK. In emergency scenario, within seconds an operator can pull the plug on any tool. The complete source code and deployment instructions are available in the Β GitHub repositoryΒ .

The problem

AI agents in production present unique operational challenges:
  1. Customer experience at risk: When a tool starts misbehaving β€” returning wrong data, timing out, or hitting a degraded backend β€” it affects every user interaction that touches it. You need a way to pull the plug on that specific tool immediately, without taking down the entire agent or disrupting the tools that still work.
  1. Redeployment is too slow for incidents: For mission-critical applications, waiting for a CI/CD pipeline to rebuild and redeploy the agent introduces unacceptable latency. An incident that could be mitigated in seconds instead takes minutes or hours, compounding the impact.

Solution overview

The solution uses AWS AppConfig as a feature flag to dynamically enable or disable individual agent tools at runtime. The agent checks the circuit breaker state inside each tool function at execution time β€” not at startup β€” so changes take effect immediately without restarting the agent.
Runtime Circuit Breakers for AI Agent Tools Architecture
ο»Ώ
How it works:
  1. User sends a message β€” For example, a user asks "Analyze my fixed network bill for account ACC-12345". The User Chat UI sends this request to the Telecom Billing Assistant Agent. It is deployed on Amazon Bedrock AgentCore Runtime.
  1. Agent sends prompt to LLM β€” The Telecom Billing Assistant Agent passes the user's prompt along with the tool definitions to Amazon Bedrock (Anthropic Claude Sonnet 4).
  1. LLM reasons and selects a tool β€” The model reads the tool descriptions, reasons about the user's request, and autonomously decides which tool to call. In this case, it selects Β fixed_network_bill_analysisΒ  because the user asked about fixed network bills. This tool is invoked.
  1. Tool Execution: Admin toggle (separate flow) β€” By default Fixed Network Bill Tool is available for process requests. Based on the situation, admin can enable AppConfig flagΒ circuit_breaker.enabledΒ  flag. It takes effect immediately. Circuit breaker check (only for Fixed Network Tool):
  • Fixed Network Bill Tool is selected β†’ first calls Β get_circuit_breaker_status()Β  which reads from AWS AppConfig.
  • If AppConfig returns Β enabled: trueΒ  β†’ tool returns a Β SERVICE_UNAVAILABLEΒ , agent tells user the service is temporarily down. You can publish any customised message.
  • If AppConfig returns Β enabled: falseΒ  β†’ tool runs Β analyze_fixed_network_bill()Β  normally.
  • If AppConfig is unreachable β†’ defaults to enabled (fail-closed, safe mode).
  1. Response β€” Agent sends the result back through Agent to the User Chat UI.

AWS services used

Before diving into the implementation, here's a brief AWS services overview used in this solution:
Β Amazon BedrockΒ  provides access to foundation models (Anthropic Claude Sonnet 4 in this demo) through a unified API. The Strands Agent uses Bedrock for LLM inference β€” reasoning about user requests and deciding which tools to call.
Β Amazon Bedrock AgentCore RuntimeΒ  Amazon Bedrock AgentCore Runtime provides a secure, serverless and purpose-built hosting environment for deploying and running AI agents or tools.
Β AWS AppConfigΒ  AWS AppConfig feature flags and dynamic configurations help software builders quickly and securely adjust application behavior in production environments without full code deployments. AWS AppConfig speeds up software release frequency, improves application resiliency, and helps you address emergent issues more quickly.
Β Strands Agents SDKΒ  is an open-source SDK for building AI agents with a model-driven approach.

Implementation details

Circuit breaker check at tool execution time

The circuit breaker is checked inside the tool function, not at agent startup. This is the key design decision:
@tool
def fixed_network_bill_analysis(account_id: str, months: int = 3) -> str:
# Check circuit breaker at execution time
if get_circuit_breaker_status():
return json.dumps({
"error": "SERVICE_UNAVAILABLE",
"message": "Fixed network bill analysis is temporarily unavailable.",
"suggestion": "Please try again later or use mobile bill analysis."
})
# Proceed with normal analysis
return json.dumps(analyze_fixed_network_bill(account_id, months))

Structured error responses

When a tool is blocked, it returns a structured JSON error instead of raising an exception. The LLM interprets this structure and responds conversationally β€” turning a hard operational control into a smooth user experience. The agent might say: "Fixed network analysis is temporarily unavailable. I can help with your mobile bill in the meantime."

Fail-closed safety

If AppConfig is unreachable (network issue, misconfiguration, etc.), the circuit breaker defaults to enabled β€” the tool is blocked. This is a deliberate design choice: when you can't verify the state of the world, the safe default is to restrict, not to allow.

AppConfig configuration

The circuit breaker is controlled via a simple JSON configuration:
{
"circuit_breaker": {
"enabled": false
}
}
Set Β enabled: trueΒ  to disable the fixed network bill tool. Set Β enabled: falseΒ  to re-enable all tools.
Follow the steps below to deploy the circuit breaker infrastructure, launch the agent, and test the pattern end-to-end in your own AWS account.

Prerequisites

  • IAM permissions for:
  • Β bedrock:InvokeModelΒ  and Β bedrock:ConverseStreamΒ 
  • Β appconfig:*Β  and Β appconfigdata:*Β 

First-time AWS setup

If you have not configured AWS CLI credentials yet, the simplest approach is the Β Β aws loginΒ Β  command, which authenticates using your existing AWS Management Console credentials:
# Login (opens browser for authentication)
aws login
ο»Ώ
# Verify you are in the right account
aws sts get-caller-identity
This generates temporary credentials. If you prefer a named profile:
aws login --profile my-account
export AWS_PROFILE=my-account
Note: Β aws loginΒ  requires AWS CLI v2.32.0+. If you use IAM Identity Center (SSO), use Β aws configure ssoΒ  and Β aws sso loginΒ  instead. See the Β AWS CLI authentication docsΒ  for all options.

Deployment

Step 1: Clone the repository and set up the environment

git clone https://github.com/aws-samples/sample-agent-tool-circuit-breaker.git
cd sample-agent-tool-circuit-breaker
ο»Ώ
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -r src/frontend/requirements.txt
pip install bedrock-agentcore-starter-toolkit

Step 2: Deploy AppConfig infrastructure

Deploy the CloudFormation stack to create AppConfig resources:
aws cloudformation deploy \
--template-file cloudformation/circuit-breaker-stack.yaml \
--stack-name circuit-breaker-agent \
--region us-east-1
This creates the AppConfig application, environment, configuration profile, and deploys the initial circuit breaker configuration (disabled β€” all tools available).
Verify the deployment:
aws cloudformation describe-stacks \
--stack-name circuit-breaker-agent \
--query 'Stacks[0].Outputs' \
--output table

Step 3: Deploy the agent to AgentCore Runtime

Configure the agent:
agentcore configure -e src/sample_agent.py
When prompted, use these values:
Prompt
Value
Agent name
Press Enter (default: sample_agent)
Region
us-east-1
Auto-create execution role
Press Enter
Auto-create ECR
Press Enter
Dependency file
Press Enter (auto-detected requirements.txt)
Configure OAuth authorizer
no (press Enter)
Configure request header allowlist
no (press Enter)
Launch the agent:
agentcore launch
This builds a container image and deploys it to AgentCore Runtime. It may take several minutes. Note the Agent ARN from the output.

Step 4: Add AppConfig permissions to the agent role

The auto-created execution role needs AppConfig permissions so the agent can read the circuit breaker flag. Find the role name in Β .bedrock_agentcore.yamlΒ  under Β execution_roleΒ  β€” it will look like Β AmazonBedrockAgentCoreSDKRuntime-us-east-1-xxxxxxxxxxΒ .
Go to the Β IAM ConsoleΒ , search for that role, and attach an inline policy with these permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"appconfig:GetLatestConfiguration",
"appconfig:StartConfigurationSession",
"appconfig:GetApplication",
"appconfig:ListApplications",
"appconfig:GetEnvironment",
"appconfig:ListEnvironments",
"appconfig:GetConfigurationProfile",
"appconfig:ListConfigurationProfiles",
"appconfig:CreateHostedConfigurationVersion",
"appconfig:StartDeployment",
"appconfig:GetDeployment"
],
"Resource": "*"
}
]
}
Give the inline policy a name and clickΒ Create Policy.
Important: Without this step, the agent cannot read AppConfig and will default to fail-closed mode (circuit breaker enabled, fixed network tool disabled).
Note: This policy uses Β "Resource": "*"Β  for simplicity. For production, scope resources to your specific AppConfig ARNs following the principle of least privilege.

Step 5: Start the Streamlit frontends

Each frontend needs its own terminal. In each new terminal, activate the virtual environment and set environment variables:
cd sample-agent-tool-circuit-breaker
source .venv/bin/activate
export AWS_REGION=us-east-1
export AGENT_ARN=<agent-arn-from-step-3>
Start the User Chat UI (Terminal 2):
streamlit run src/frontend/app.py
Start the Admin Dashboard (Terminal 3):
streamlit run src/frontend/admin_app.py --server.port 8502

Step 6: Test the circuit breaker

With both frontends running, verify the circuit breaker works end-to-end:
6a. Test with circuit breaker disabled (default)
Open the User Chat UI and ask:
  • "Analyze my mobile bill for account ACC-12345"
  • "Analyze my fixed network bill for account ACC-12345"
Both should return analysis results. The Admin Dashboard should show both tools as available.
6b. Enable the circuit breaker
Either click "ENABLE CIRCUIT BREAKER" in the Admin Dashboard, or run in a terminal:
python scripts/toggle_circuit_breaker.py --enable
The Admin Dashboard will show:
🌐 Fixed Network Analysis
⚠️ Temporarily Unavailable
6c. Test with circuit breaker enabled
Refresh the Chat UI and ask "Analyze my fixed network bill for account ACC-12345". The agent will respond gracefully:
"It looks like the fixed network bill analysis service is currently unavailable due to maintenance. I can still help with your mobile bill analysis. You may want to try the fixed network analysis again later when the service is restored."
The agent doesn't crash or return a raw error β€” it interprets the structured Β SERVICE_UNAVAILABLEΒ  response and communicates naturally to the user, suggesting alternatives.
Note: This sample code is intended for demonstration purposes only. It illustrates the runtime circuit breaker pattern for AI agent tools. For production deployments, additional considerations such as scoped IAM policies, monitoring, error handling, and security hardening may be required based on your specific use case.

Extending the pattern

This pattern can be adapted for many production scenarios:
Industry
Agent Use Case
Circuit Breaker Application
Financial Services
Trading assistant
Disable trade execution during market volatility
Healthcare
Clinical decision support
Disable drug interaction tool during formulary updates
E-commerce
Shopping concierge
Disable inventory lookup during warehouse migration
SRE/DevOps
Incident response agent
Disable auto-remediation during change freeze windows

Best practices

Circuit breaker design:
  • Default to fail-closed (tool disabled) when the configuration source is unreachable.
  • Use structured error responses so the agent can communicate gracefully to users.
  • Check the circuit breaker at tool execution time, not at agent startup, to allow real-time control.
AppConfig operations:
  • Store your circuit breaker configuration in version control alongside the agent code.
  • Use theΒ Β AllAtOnceΒ Β with zero Bake time deployment strategy for instant propagation during incidents.
  • Set up CloudWatch alarms on AppConfig deployment failures.

Project structure

sample-agent-tool-circuit-breaker/
β”œβ”€β”€ cloudformation/
β”‚ └── circuit-breaker-stack.yaml # AppConfig + IAM infrastructure
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ sample_agent.py # Main agent with AppConfig integration
β”‚ β”œβ”€β”€ tools.py # Bill analysis tool implementations
β”‚ └── frontend/
β”‚ β”œβ”€β”€ app.py # User chat interface (Streamlit)
β”‚ β”œβ”€β”€ admin_app.py # Admin dashboard (Streamlit)
β”‚ └── requirements.txt # Frontend dependencies
β”œβ”€β”€ scripts/
β”‚ β”œβ”€β”€ toggle_circuit_breaker.py # CLI to toggle the circuit breaker
β”‚ └── deploy_agent.py # AgentCore deployment script
β”œβ”€β”€ tests/
β”‚ └── test_agent.py # Test suite
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ Dockerfile # Container image for AgentCore deployment
β”œβ”€β”€ deploy.sh # Quick setup script
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ LICENSE
└── README.md

Cleanup

To remove all resources created by this demo:
aws cloudformation delete-stack --stack-name circuit-breaker-agent
aws cloudformation wait stack-delete-complete --stack-name circuit-breaker-agent
This deletes the AppConfig application, environment, configuration profile, and IAM role in one command.

Conclusion

Runtime circuit breakers give operations teams the control they need over AI agents in production. By combining AWS AppConfig with the Strands Agents SDK and Amazon Bedrock AgentCore, organizations can dynamically enable or disable individual agent tools in seconds β€” without redeployment, without restarts, and without disrupting the tools that are still working.
For more information about building AI agents on AWS, see the Β Strands Agents SDKΒ  and Β Amazon Bedrock AgentCore documentationΒ .

ο»Ώ

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article