AWSRichard WhitworthTutorial
Resilience testing your agents on Amazon Bedrock AgentCore
Summary
AI agents that rely on tools can fail silently or produce confident but incorrect answers when those tools break. This post introduces a method for testing agent resilience by injecting tool-level faults using AWS Fault Injection Service (AWS FIS) and AWS Systems Manager (SSM). Faults are classified into pre-hook faults, which cancel a tool call before execution, and post-hook faults, which corrupt the tool’s response after it runs. The agent runs on Amazon Bedrock AgentCore with the Strands framework, and fault injection is controlled via SSM Parameter Store, enabling dynamic activation without redeployment. Observability is built through Embedded Metric Format and Pydantic constraints, allowing teams to detect safe failures versus silent data corruption in agent behavior.
Context
In production, tools like databases and APIs can fail, and agents may react unpredictably, presenting fabricated answers or raw errors. This tutorial addresses the need to test agent behavior under such conditions using controlled chaos experiments.
Approach / What changed
Integrate chaos_plugins() into the agent constructor. Deploy an SSM Automation document (ChaosExperiment) that writes fault configurations to Parameter Store under /chaos/{runtime_id}/. AWS FIS starts the experiment, setting active=true after writing all parameters. The agent’s controller reads these parameters on each invocation and injects pre-hook faults (cancel tool call with errors like timeout) or post-hook faults (corrupt response with truncate, remove, or corrupt actions). Observability uses Embedded Metric Format to log tool-level outcomes and constraints to validate responses.
Takeaways
Pre-hook faults cancel the tool call before execution and return an error (timeout, network_error, etc.), testing if the agent gracefully handles failures.
Post-hook faults let the tool run but corrupt its response (truncate_fields, remove_fields, corrupt_values), revealing if the agent unknowingly uses bad data.
Use Embedded Metric Format and Pydantic constraints to detect corrupted or incomplete tool outputs, enabling alarms on safe failures versus silent data corruption.
FAQ
What is the difference between pre-hook and post-hook faults?
Pre-hook faults cancel the tool call before it executes and return an error to the agent. Post-hook faults let the tool run but then corrupt its response, testing whether the agent detects and handles incorrect data.
How do I define a hypothesis for resilience testing?
Specify the expected agent behavior when tool calls are canceled or corrupted, including safe failure actions and alerting thresholds. For example: 'When tool calls are canceled, the agent should notify the user and not fabricate an answer; after three failed calls in five minutes, an alarm should fire.'
Can I run chaos experiments on production agents?
No. The post recommends using a dedicated chaos runtime that includes chaos_plugins() and has read access to /chaos/*. Production runtimes should omit the plugins and not have that permissions path.
Source and freshness
- Source
- aws.amazon.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.