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

ο»Ώ
Β ο»ΏΒ
How it works:
- 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.
- 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).
- 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.
- 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).
- 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.
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:
@tooldef 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
- An Β AWS accountΒ
- Β AWS CLI v2.32.0+Β installed
- Β Amazon Bedrock model accessΒ enabled for Claude Sonnet 4 in your region
- 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 accountaws sts get-caller-identityThis generates temporary credentials. If you prefer a named profile:
aws login --profile my-accountexport AWS_PROFILE=my-accountNote: Β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.gitcd sample-agent-tool-circuit-breakerο»Ώ
python3 -m venv .venvsource .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txtpip install -r src/frontend/requirements.txtpip install bedrock-agentcore-starter-toolkitStep 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-1This 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 tableStep 3: Deploy the agent to AgentCore Runtime
Configure the agent:
agentcore configure -e src/sample_agent.pyWhen 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 launchThis 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-breakersource .venv/bin/activateexport AWS_REGION=us-east-1export AGENT_ARN=<agent-arn-from-step-3>Start the User Chat UI (Terminal 2):
streamlit run src/frontend/app.pyStart the Admin Dashboard (Terminal 3):
streamlit run src/frontend/admin_app.py --server.port 8502- User View (Β http://localhost:8501Β ): Chat with the billing agent, see available services
- Admin View (Β http://localhost:8502Β ): Toggle the circuit breaker on/off with a single click
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 --enableThe Admin Dashboard will show:
π Fixed Network Analysisβ οΈ Temporarily Unavailable6c. 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.mdCleanup
To remove all resources created by this demo:
aws cloudformation delete-stack --stack-name circuit-breaker-agentaws cloudformation wait stack-delete-complete --stack-name circuit-breaker-agentThis 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Β .
ο»Ώ
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article