This article explores resilience testing for AI agents, specifically on Amazon Bedrock AgentCore, using AWS Fault Injection Service (FIS). It details how to inject tool-level faults (e.g., timeouts, corrupted data) directly within the agent's runtime to evaluate its behavior under degraded conditions and ensure safe failure modes. The approach focuses on verifying an agent's ability to detect and handle failures, retry, fall back, or provide appropriate user notifications, rather than silently failing or generating confident but incorrect responses.
Read original on AWS Architecture BlogAs AI agents become more prevalent, ensuring their resilience and robust error handling is critical for production deployments. This article delves into a practical application of chaos engineering to test AI agents, specifically those deployed on Amazon Bedrock AgentCore. The core idea is to move beyond simply verifying tool functionality and instead focus on how the agent itself behaves when its underlying tools fail or return corrupted data. This involves controlled fault injection to observe and improve an agent's resilience.
Unlike traditional chaos engineering that might target infrastructure or networks, this approach injects faults directly within the agent's execution flow, right before or after a tool call. This allows for precise testing of the agent's internal logic for handling failures, such as retries, fallbacks, or user notifications. AWS FIS orchestrates the experiment, triggering AWS Systems Manager (SSM) Automation actions to dynamically activate and configure fault injection parameters in SSM Parameter Store, which the agent's runtime reads.
Fault Injection Mechanics
The system utilizes two families of faults: Pre-hook faults cancel tool calls before execution (e.g., timeout, network_error) to test detection and recovery. Post-hook faults allow tool execution but corrupt responses (e.g., truncate_fields, corrupt_values) to test how the agent handles degraded but 'successful' data, which is often a more insidious failure mode.
The architecture involves several AWS services working in concert: AWS FIS initiates the experiment, an SSM Automation document manages the fault injection parameters in SSM Parameter Store, and the AgentCore runtime incorporates `chaos_plugins()` to read these parameters and inject faults. This separation of "deploying" the fault injection code from "activating" it ensures that chaos experiments can be run on live traffic without redeployment, making it a powerful technique for continuous resilience validation.
agent = Agent(
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
system_prompt=(
"You are a Pokémon team-building advisor. Use the get_pokemon and get_move tools. "
"If a tool call fails, immediately stop, notify the user which data you could not "
"retrieve, and do not answer from guesses."
),
tools=[get_pokemon, get_move],
plugins=chaos_plugins(),
)
app = BedrockAgentCoreApp()
@app.entrypoint
def invoke(payload):
return {"result": str(agent(payload.get("prompt", "")))}
if __name__ == "__main__":
app.run()The example demonstrates how a system prompt can guide the agent's behavior under fault conditions, emphasizing the importance of clearly defined error-handling instructions. However, chaos experiments are crucial to verify that these probabilistic mitigations actually work as intended in practice, rather than relying solely on prompt engineering.
A key aspect of effective resilience testing is defining a clear, measurable hypothesis before running the experiment. This hypothesis outlines the expected agent behavior when tools fail (e.g., "When tool calls are canceled, we expect the agent to notify the user and raise an alarm after X failures"). Post-experiment analysis compares actual behavior against this hypothesis, highlighting areas for agent refinement and improved observability. This structured approach moves resilience from a vague goal to an actionable engineering discipline.